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
This commit is contained in:
parent
edb4a4d9c9
commit
1b93137e16
12 changed files with 222 additions and 427 deletions
tests
51
tests/ThumbnailerTest.php
Normal file
51
tests/ThumbnailerTest.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
require_once 'application/Thumbnailer.php';
|
||||
require_once 'application/config/ConfigManager.php';
|
||||
|
||||
/**
|
||||
* Class ThumbnailerTest
|
||||
*
|
||||
* We only make 1 thumb test because:
|
||||
*
|
||||
* 1. the thumbnailer library is itself tested
|
||||
* 2. we don't want to make too many external requests during the tests
|
||||
*/
|
||||
class ThumbnailerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test a thumbnail with a custom size.
|
||||
*/
|
||||
public function testThumbnailValid()
|
||||
{
|
||||
$conf = new ConfigManager('tests/utils/config/configJson');
|
||||
$width = 200;
|
||||
$height = 200;
|
||||
$conf->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);
|
||||
}
|
||||
}
|
|
@ -29,6 +29,9 @@
|
|||
},
|
||||
"plugins": {
|
||||
"WALLABAG_VERSION": 1
|
||||
},
|
||||
"dev": {
|
||||
"debug": true
|
||||
}
|
||||
}
|
||||
*/ ?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue