aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ThumbnailerTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-11-09 18:57:02 +0100
committerArthurHoaro <arthur@hoa.ro>2018-07-05 20:31:35 +0200
commit1b93137e16694f52952c930848e1a7928e8a00a6 (patch)
tree3d2c69d1c3bd1a85e1e46b04c55fc3978b5ebde8 /tests/ThumbnailerTest.php
parentedb4a4d9c9fbc01d67ee8d095fe26648714e2285 (diff)
downloadShaarli-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/ThumbnailerTest.php')
-rw-r--r--tests/ThumbnailerTest.php51
1 files changed, 51 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
3require_once 'application/Thumbnailer.php';
4require_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 */
14class 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}