aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ThumbnailerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ThumbnailerTest.php')
-rw-r--r--tests/ThumbnailerTest.php43
1 files changed, 36 insertions, 7 deletions
diff --git a/tests/ThumbnailerTest.php b/tests/ThumbnailerTest.php
index c04b8fb5..08311545 100644
--- a/tests/ThumbnailerTest.php
+++ b/tests/ThumbnailerTest.php
@@ -25,14 +25,20 @@ class ThumbnailerTest extends TestCase
25 */ 25 */
26 protected $thumbnailer; 26 protected $thumbnailer;
27 27
28 /**
29 * @var ConfigManager
30 */
31 protected $conf;
32
28 public function setUp() 33 public function setUp()
29 { 34 {
30 $conf = new ConfigManager('tests/utils/config/configJson'); 35 $this->conf = new ConfigManager('tests/utils/config/configJson');
31 $conf->set('thumbnails.width', self::WIDTH); 36 $this->conf->set('thumbnails.mode', Thumbnailer::MODE_ALL);
32 $conf->set('thumbnails.height', self::HEIGHT); 37 $this->conf->set('thumbnails.width', self::WIDTH);
33 $conf->set('dev.debug', true); 38 $this->conf->set('thumbnails.height', self::HEIGHT);
39 $this->conf->set('dev.debug', true);
34 40
35 $this->thumbnailer = new Thumbnailer($conf); 41 $this->thumbnailer = new Thumbnailer($this->conf);
36 // cache files in the sandbox 42 // cache files in the sandbox
37 WTConfigManager::addFile('tests/utils/config/wt.json'); 43 WTConfigManager::addFile('tests/utils/config/wt.json');
38 } 44 }
@@ -43,9 +49,9 @@ class ThumbnailerTest extends TestCase
43 } 49 }
44 50
45 /** 51 /**
46 * Test a thumbnail with a custom size. 52 * Test a thumbnail with a custom size in 'all' mode.
47 */ 53 */
48 public function testThumbnailValid() 54 public function testThumbnailAllValid()
49 { 55 {
50 $thumb = $this->thumbnailer->get('https://github.com/shaarli/Shaarli/'); 56 $thumb = $this->thumbnailer->get('https://github.com/shaarli/Shaarli/');
51 $this->assertNotFalse($thumb); 57 $this->assertNotFalse($thumb);
@@ -55,6 +61,29 @@ class ThumbnailerTest extends TestCase
55 } 61 }
56 62
57 /** 63 /**
64 * Test a thumbnail with a custom size in 'common' mode.
65 */
66 public function testThumbnailCommonValid()
67 {
68 $this->conf->set('thumbnails.mode', Thumbnailer::MODE_COMMON);
69 $thumb = $this->thumbnailer->get('https://imgur.com/jlFgGpe');
70 $this->assertNotFalse($thumb);
71 $image = imagecreatefromstring(file_get_contents($thumb));
72 $this->assertEquals(self::WIDTH, imagesx($image));
73 $this->assertEquals(self::HEIGHT, imagesy($image));
74 }
75
76 /**
77 * Test a thumbnail in 'common' mode which isn't include in common websites.
78 */
79 public function testThumbnailCommonInvalid()
80 {
81 $this->conf->set('thumbnails.mode', Thumbnailer::MODE_COMMON);
82 $thumb = $this->thumbnailer->get('https://github.com/shaarli/Shaarli/');
83 $this->assertFalse($thumb);
84 }
85
86 /**
58 * Test a thumbnail that can't be retrieved. 87 * Test a thumbnail that can't be retrieved.
59 */ 88 */
60 public function testThumbnailNotValid() 89 public function testThumbnailNotValid()