From 1b93137e16694f52952c930848e1a7928e8a00a6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 9 Nov 2016 18:57:02 +0100 Subject: Use web-thumbnailer to retrieve thumbnails * requires PHP 5.6 * use blazy on linklist since a lot more thumbs are retrieved * thumbnails can be disabled * thumbs size is now 120x120 * thumbs are now cropped to fit the expected size Fixes #345 #425 #487 #543 #588 #590 --- tests/ThumbnailerTest.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/ThumbnailerTest.php (limited to 'tests/ThumbnailerTest.php') diff --git a/tests/ThumbnailerTest.php b/tests/ThumbnailerTest.php new file mode 100644 index 00000000..db109321 --- /dev/null +++ b/tests/ThumbnailerTest.php @@ -0,0 +1,51 @@ +set('thumbnails.width', $width); + $conf->set('thumbnails.height', $height); + + $thumbnailer = new Thumbnailer($conf); + $thumb = $thumbnailer->get('https://github.com/shaarli/Shaarli/'); + $this->assertNotFalse($thumb); + $image = imagecreatefromstring(file_get_contents($thumb)); + $this->assertEquals($width, imagesx($image)); + $this->assertEquals($height, imagesy($image)); + } + + /** + * Test a thumbnail that can't be retrieved. + * + * @expectedException WebThumbnailer\Exception\ThumbnailNotFoundException + */ + public function testThumbnailNotValid() + { + $oldlog = ini_get('error_log'); + ini_set('error_log', '/dev/null'); + + $thumbnailer = new Thumbnailer(new ConfigManager()); + $thumb = $thumbnailer->get('nope'); + $this->assertFalse($thumb); + + ini_set('error_log', $oldlog); + } +} -- cgit v1.2.3