3 require_once 'application/Thumbnailer.php';
4 require_once 'application/config/ConfigManager.php';
7 * Class ThumbnailerTest
9 * We only make 1 thumb test because:
11 * 1. the thumbnailer library is itself tested
12 * 2. we don't want to make too many external requests during the tests
14 class ThumbnailerTest
extends PHPUnit_Framework_TestCase
17 * Test a thumbnail with a custom size.
19 public function testThumbnailValid()
21 $conf = new ConfigManager('tests/utils/config/configJson');
24 $conf->set('thumbnails.width', $width);
25 $conf->set('thumbnails.height', $height);
27 $thumbnailer = new Thumbnailer($conf);
28 $thumb = $thumbnailer->get('https://github.com/shaarli/Shaarli/');
29 $this->assertNotFalse($thumb);
30 $image = imagecreatefromstring(file_get_contents($thumb));
31 $this->assertEquals($width, imagesx($image));
32 $this->assertEquals($height, imagesy($image));
36 * Test a thumbnail that can't be retrieved.
38 * @expectedException WebThumbnailer\Exception\ThumbnailNotFoundException
40 public function testThumbnailNotValid()
42 $oldlog = ini_get('error_log');
43 ini_set('error_log', '/dev/null');
45 $thumbnailer = new Thumbnailer(new ConfigManager());
46 $thumb = $thumbnailer->get('nope');
47 $this->assertFalse($thumb);
49 ini_set('error_log', $oldlog);