From e85b7a05a177f803ae36ba5c12835313f31177bc Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 11 Nov 2017 14:01:21 +0100 Subject: Update thumbnail integration after rebasing the branch --- tests/ThumbnailerTest.php | 64 +++++++++++++++++++++++-------- tests/Updater/UpdaterTest.php | 15 ++++++++ tests/utils/config/configJson.json.php | 70 ++++++++++++++++++++++++++++------ tests/utils/config/wt.json | 12 ++++++ 4 files changed, 134 insertions(+), 27 deletions(-) create mode 100644 tests/utils/config/wt.json (limited to 'tests') diff --git a/tests/ThumbnailerTest.php b/tests/ThumbnailerTest.php index db109321..c04b8fb5 100644 --- a/tests/ThumbnailerTest.php +++ b/tests/ThumbnailerTest.php @@ -1,7 +1,10 @@ set('thumbnails.width', $width); - $conf->set('thumbnails.height', $height); + $conf->set('thumbnails.width', self::WIDTH); + $conf->set('thumbnails.height', self::HEIGHT); + $conf->set('dev.debug', true); + + $this->thumbnailer = new Thumbnailer($conf); + // cache files in the sandbox + WTConfigManager::addFile('tests/utils/config/wt.json'); + } + + public function tearDown() + { + $this->rrmdirContent('sandbox/'); + } - $thumbnailer = new Thumbnailer($conf); - $thumb = $thumbnailer->get('https://github.com/shaarli/Shaarli/'); + /** + * Test a thumbnail with a custom size. + */ + public function testThumbnailValid() + { + $thumb = $this->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)); + $this->assertEquals(self::WIDTH, imagesx($image)); + $this->assertEquals(self::HEIGHT, imagesy($image)); } /** * Test a thumbnail that can't be retrieved. - * - * @expectedException WebThumbnailer\Exception\ThumbnailNotFoundException */ public function testThumbnailNotValid() { @@ -48,4 +68,18 @@ class ThumbnailerTest extends PHPUnit_Framework_TestCase ini_set('error_log', $oldlog); } + + protected function rrmdirContent($dir) { + if (is_dir($dir)) { + $objects = scandir($dir); + foreach ($objects as $object) { + if ($object != "." && $object != "..") { + if (is_dir($dir."/".$object)) + $this->rrmdirContent($dir."/".$object); + else + unlink($dir."/".$object); + } + } + } + } } diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php index 94e3c7d3..8b90fd5e 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php @@ -684,4 +684,19 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; $this->assertEquals(4194304, $this->conf->get('general.download_max_size')); $this->assertEquals(3, $this->conf->get('general.download_timeout')); } + + /** + * Test updateMethodAtomDefault with show_atom set to true. + * => nothing to do + */ + public function testUpdateMethodWebThumbnailerEnabled() + { + $this->conf->set('thumbnail.enable_thumbnails', true); + $updater = new Updater([], [], $this->conf, true); + $this->assertTrue($updater->updateMethodWebThumbnailer()); + $this->assertFalse($this->conf->exists('thumbnail')); + $this->assertTrue($this->conf->get('thumbnails.enabled')); + $this->assertEquals(125, $this->conf->get('thumbnails.width')); + $this->assertEquals(90, $this->conf->get('thumbnails.height')); + } } diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php index 3101b225..061d4c28 100644 --- a/tests/utils/config/configJson.json.php +++ b/tests/utils/config/configJson.json.php @@ -1,38 +1,84 @@ - +*/ ?> \ No newline at end of file diff --git a/tests/utils/config/wt.json b/tests/utils/config/wt.json new file mode 100644 index 00000000..69ce49a6 --- /dev/null +++ b/tests/utils/config/wt.json @@ -0,0 +1,12 @@ +{ + "settings": { + "default": { + "_comment": "infinite cache", + "cache_duration": -1, + "timeout": 10 + }, + "path": { + "cache": "sandbox/" + } + } +} \ No newline at end of file -- cgit v1.2.3