diff options
author | ArthurHoaro <arthur@hoa.ro> | 2018-07-28 09:41:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-28 09:41:29 +0200 |
commit | ad5f47adbaee1eef85e90950ab8a45fe82959924 (patch) | |
tree | d23a186661db00d36cb2b2287a7bf890fbc62cfb /tests/Updater/UpdaterTest.php | |
parent | 8fdd65b88412a0db28c723a486650c434fe5668c (diff) | |
parent | 7b4fea0e39be9e74e9aef13e73af9bbd2b1a6397 (diff) | |
download | Shaarli-ad5f47adbaee1eef85e90950ab8a45fe82959924.tar.gz Shaarli-ad5f47adbaee1eef85e90950ab8a45fe82959924.tar.zst Shaarli-ad5f47adbaee1eef85e90950ab8a45fe82959924.zip |
Merge pull request #687 from ArthurHoaro/web-thumb
Use web-thumbnailer to retrieve thumbnails
Diffstat (limited to 'tests/Updater/UpdaterTest.php')
-rw-r--r-- | tests/Updater/UpdaterTest.php | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php index 94e3c7d3..cacee2d2 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php | |||
@@ -2,6 +2,7 @@ | |||
2 | use Shaarli\Config\ConfigJson; | 2 | use Shaarli\Config\ConfigJson; |
3 | use Shaarli\Config\ConfigManager; | 3 | use Shaarli\Config\ConfigManager; |
4 | use Shaarli\Config\ConfigPhp; | 4 | use Shaarli\Config\ConfigPhp; |
5 | use Shaarli\Thumbnailer; | ||
5 | 6 | ||
6 | require_once 'tests/Updater/DummyUpdater.php'; | 7 | require_once 'tests/Updater/DummyUpdater.php'; |
7 | require_once 'inc/rain.tpl.class.php'; | 8 | require_once 'inc/rain.tpl.class.php'; |
@@ -20,7 +21,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase | |||
20 | /** | 21 | /** |
21 | * @var string Config file path (without extension). | 22 | * @var string Config file path (without extension). |
22 | */ | 23 | */ |
23 | protected static $configFile = 'tests/utils/config/configJson'; | 24 | protected static $configFile = 'sandbox/config'; |
24 | 25 | ||
25 | /** | 26 | /** |
26 | * @var ConfigManager | 27 | * @var ConfigManager |
@@ -32,6 +33,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase | |||
32 | */ | 33 | */ |
33 | public function setUp() | 34 | public function setUp() |
34 | { | 35 | { |
36 | copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); | ||
35 | $this->conf = new ConfigManager(self::$configFile); | 37 | $this->conf = new ConfigManager(self::$configFile); |
36 | } | 38 | } |
37 | 39 | ||
@@ -684,4 +686,50 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; | |||
684 | $this->assertEquals(4194304, $this->conf->get('general.download_max_size')); | 686 | $this->assertEquals(4194304, $this->conf->get('general.download_max_size')); |
685 | $this->assertEquals(3, $this->conf->get('general.download_timeout')); | 687 | $this->assertEquals(3, $this->conf->get('general.download_timeout')); |
686 | } | 688 | } |
689 | |||
690 | /** | ||
691 | * Test updateMethodWebThumbnailer with thumbnails enabled. | ||
692 | */ | ||
693 | public function testUpdateMethodWebThumbnailerEnabled() | ||
694 | { | ||
695 | $this->conf->remove('thumbnails'); | ||
696 | $this->conf->set('thumbnail.enable_thumbnails', true); | ||
697 | $updater = new Updater([], [], $this->conf, true, $_SESSION); | ||
698 | $this->assertTrue($updater->updateMethodWebThumbnailer()); | ||
699 | $this->assertFalse($this->conf->exists('thumbnail')); | ||
700 | $this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode')); | ||
701 | $this->assertEquals(125, $this->conf->get('thumbnails.width')); | ||
702 | $this->assertEquals(90, $this->conf->get('thumbnails.height')); | ||
703 | $this->assertContains('You have enabled or changed thumbnails', $_SESSION['warnings'][0]); | ||
704 | } | ||
705 | |||
706 | /** | ||
707 | * Test updateMethodWebThumbnailer with thumbnails disabled. | ||
708 | */ | ||
709 | public function testUpdateMethodWebThumbnailerDisabled() | ||
710 | { | ||
711 | $this->conf->remove('thumbnails'); | ||
712 | $this->conf->set('thumbnail.enable_thumbnails', false); | ||
713 | $updater = new Updater([], [], $this->conf, true, $_SESSION); | ||
714 | $this->assertTrue($updater->updateMethodWebThumbnailer()); | ||
715 | $this->assertFalse($this->conf->exists('thumbnail')); | ||
716 | $this->assertEquals(Thumbnailer::MODE_NONE, $this->conf->get('thumbnails.mode')); | ||
717 | $this->assertEquals(125, $this->conf->get('thumbnails.width')); | ||
718 | $this->assertEquals(90, $this->conf->get('thumbnails.height')); | ||
719 | $this->assertTrue(empty($_SESSION['warnings'])); | ||
720 | } | ||
721 | |||
722 | /** | ||
723 | * Test updateMethodWebThumbnailer with thumbnails disabled. | ||
724 | */ | ||
725 | public function testUpdateMethodWebThumbnailerNothingToDo() | ||
726 | { | ||
727 | $updater = new Updater([], [], $this->conf, true, $_SESSION); | ||
728 | $this->assertTrue($updater->updateMethodWebThumbnailer()); | ||
729 | $this->assertFalse($this->conf->exists('thumbnail')); | ||
730 | $this->assertEquals(Thumbnailer::MODE_COMMON, $this->conf->get('thumbnails.mode')); | ||
731 | $this->assertEquals(90, $this->conf->get('thumbnails.width')); | ||
732 | $this->assertEquals(53, $this->conf->get('thumbnails.height')); | ||
733 | $this->assertTrue(empty($_SESSION['warnings'])); | ||
734 | } | ||
687 | } | 735 | } |