aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Updater/UpdaterTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-03-13 18:02:49 +0100
committerGitHub <noreply@github.com>2018-03-13 18:02:49 +0100
commit4294bc7b98c8f45ceaac867cad3d5d35ee9eb096 (patch)
treed958d8d0cfab382250054cd610f0dd6f7880f67a /tests/Updater/UpdaterTest.php
parent39ee93925b66b527c4386647001fadc898c52a2c (diff)
parent4ff3ed1c47365d5b28f70cb2921b0ac0075612c3 (diff)
downloadShaarli-4294bc7b98c8f45ceaac867cad3d5d35ee9eb096.tar.gz
Shaarli-4294bc7b98c8f45ceaac867cad3d5d35ee9eb096.tar.zst
Shaarli-4294bc7b98c8f45ceaac867cad3d5d35ee9eb096.zip
Merge pull request #1096 from ArthurHoaro/feature/download-params
Make max download size and timeout configurable
Diffstat (limited to 'tests/Updater/UpdaterTest.php')
-rw-r--r--tests/Updater/UpdaterTest.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php
index fed175df..94e3c7d3 100644
--- a/tests/Updater/UpdaterTest.php
+++ b/tests/Updater/UpdaterTest.php
@@ -620,4 +620,68 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
620 $this->assertTrue($updater->updateMethodAtomDefault()); 620 $this->assertTrue($updater->updateMethodAtomDefault());
621 $this->assertTrue($this->conf->get('feed.show_atom')); 621 $this->assertTrue($this->conf->get('feed.show_atom'));
622 } 622 }
623
624 /**
625 * Test updateMethodDownloadSizeAndTimeoutConf, it should be set if none is already defined.
626 */
627 public function testUpdateMethodDownloadSizeAndTimeoutConf()
628 {
629 $sandboxConf = 'sandbox/config';
630 copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
631 $this->conf = new ConfigManager($sandboxConf);
632 $updater = new Updater([], [], $this->conf, true);
633 $this->assertTrue($updater->updateMethodDownloadSizeAndTimeoutConf());
634 $this->assertEquals(4194304, $this->conf->get('general.download_max_size'));
635 $this->assertEquals(30, $this->conf->get('general.download_timeout'));
636
637 $this->conf = new ConfigManager($sandboxConf);
638 $this->assertEquals(4194304, $this->conf->get('general.download_max_size'));
639 $this->assertEquals(30, $this->conf->get('general.download_timeout'));
640 }
641
642 /**
643 * Test updateMethodDownloadSizeAndTimeoutConf, it shouldn't be set if it is already defined.
644 */
645 public function testUpdateMethodDownloadSizeAndTimeoutConfIgnore()
646 {
647 $sandboxConf = 'sandbox/config';
648 copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
649 $this->conf = new ConfigManager($sandboxConf);
650 $this->conf->set('general.download_max_size', 38);
651 $this->conf->set('general.download_timeout', 70);
652 $updater = new Updater([], [], $this->conf, true);
653 $this->assertTrue($updater->updateMethodDownloadSizeAndTimeoutConf());
654 $this->assertEquals(38, $this->conf->get('general.download_max_size'));
655 $this->assertEquals(70, $this->conf->get('general.download_timeout'));
656 }
657
658 /**
659 * Test updateMethodDownloadSizeAndTimeoutConf, only the maz size should be set here.
660 */
661 public function testUpdateMethodDownloadSizeAndTimeoutConfOnlySize()
662 {
663 $sandboxConf = 'sandbox/config';
664 copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
665 $this->conf = new ConfigManager($sandboxConf);
666 $this->conf->set('general.download_max_size', 38);
667 $updater = new Updater([], [], $this->conf, true);
668 $this->assertTrue($updater->updateMethodDownloadSizeAndTimeoutConf());
669 $this->assertEquals(38, $this->conf->get('general.download_max_size'));
670 $this->assertEquals(30, $this->conf->get('general.download_timeout'));
671 }
672
673 /**
674 * Test updateMethodDownloadSizeAndTimeoutConf, only the time out should be set here.
675 */
676 public function testUpdateMethodDownloadSizeAndTimeoutConfOnlyTimeout()
677 {
678 $sandboxConf = 'sandbox/config';
679 copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
680 $this->conf = new ConfigManager($sandboxConf);
681 $this->conf->set('general.download_timeout', 3);
682 $updater = new Updater([], [], $this->conf, true);
683 $this->assertTrue($updater->updateMethodDownloadSizeAndTimeoutConf());
684 $this->assertEquals(4194304, $this->conf->get('general.download_max_size'));
685 $this->assertEquals(3, $this->conf->get('general.download_timeout'));
686 }
623} 687}