aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Updater/UpdaterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Updater/UpdaterTest.php')
-rw-r--r--tests/Updater/UpdaterTest.php50
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 @@
2use Shaarli\Config\ConfigJson; 2use Shaarli\Config\ConfigJson;
3use Shaarli\Config\ConfigManager; 3use Shaarli\Config\ConfigManager;
4use Shaarli\Config\ConfigPhp; 4use Shaarli\Config\ConfigPhp;
5use Shaarli\Thumbnailer;
5 6
6require_once 'tests/Updater/DummyUpdater.php'; 7require_once 'tests/Updater/DummyUpdater.php';
7require_once 'inc/rain.tpl.class.php'; 8require_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}