diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ThumbnailerTest.php | 51 | ||||
-rw-r--r-- | tests/utils/config/configJson.json.php | 3 |
2 files changed, 54 insertions, 0 deletions
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 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'application/Thumbnailer.php'; | ||
4 | require_once 'application/config/ConfigManager.php'; | ||
5 | |||
6 | /** | ||
7 | * Class ThumbnailerTest | ||
8 | * | ||
9 | * We only make 1 thumb test because: | ||
10 | * | ||
11 | * 1. the thumbnailer library is itself tested | ||
12 | * 2. we don't want to make too many external requests during the tests | ||
13 | */ | ||
14 | class ThumbnailerTest extends PHPUnit_Framework_TestCase | ||
15 | { | ||
16 | /** | ||
17 | * Test a thumbnail with a custom size. | ||
18 | */ | ||
19 | public function testThumbnailValid() | ||
20 | { | ||
21 | $conf = new ConfigManager('tests/utils/config/configJson'); | ||
22 | $width = 200; | ||
23 | $height = 200; | ||
24 | $conf->set('thumbnails.width', $width); | ||
25 | $conf->set('thumbnails.height', $height); | ||
26 | |||
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)); | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * Test a thumbnail that can't be retrieved. | ||
37 | * | ||
38 | * @expectedException WebThumbnailer\Exception\ThumbnailNotFoundException | ||
39 | */ | ||
40 | public function testThumbnailNotValid() | ||
41 | { | ||
42 | $oldlog = ini_get('error_log'); | ||
43 | ini_set('error_log', '/dev/null'); | ||
44 | |||
45 | $thumbnailer = new Thumbnailer(new ConfigManager()); | ||
46 | $thumb = $thumbnailer->get('nope'); | ||
47 | $this->assertFalse($thumb); | ||
48 | |||
49 | ini_set('error_log', $oldlog); | ||
50 | } | ||
51 | } | ||
diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php index 9c9288f3..3101b225 100644 --- a/tests/utils/config/configJson.json.php +++ b/tests/utils/config/configJson.json.php | |||
@@ -29,6 +29,9 @@ | |||
29 | }, | 29 | }, |
30 | "plugins": { | 30 | "plugins": { |
31 | "WALLABAG_VERSION": 1 | 31 | "WALLABAG_VERSION": 1 |
32 | }, | ||
33 | "dev": { | ||
34 | "debug": true | ||
32 | } | 35 | } |
33 | } | 36 | } |
34 | */ ?> | 37 | */ ?> |