diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-11-09 18:57:02 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2018-07-05 20:31:35 +0200 |
commit | 1b93137e16694f52952c930848e1a7928e8a00a6 (patch) | |
tree | 3d2c69d1c3bd1a85e1e46b04c55fc3978b5ebde8 /tests | |
parent | edb4a4d9c9fbc01d67ee8d095fe26648714e2285 (diff) | |
download | Shaarli-1b93137e16694f52952c930848e1a7928e8a00a6.tar.gz Shaarli-1b93137e16694f52952c930848e1a7928e8a00a6.tar.zst Shaarli-1b93137e16694f52952c930848e1a7928e8a00a6.zip |
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
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 | */ ?> |