summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-11-11 19:36:04 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2020-11-12 11:57:28 +0100
commitec92e82571223eef996c526640b2767a27fdfb0d (patch)
tree4e26ee1c06e87342940e934fd3ec02cbd9bd39af /tests/lib
parent4dbeab5cff0702af48280bc202040ce2e91a797b (diff)
downloadnextcloud-server-ec92e82571223eef996c526640b2767a27fdfb0d.tar.gz
nextcloud-server-ec92e82571223eef996c526640b2767a27fdfb0d.zip
Add unit tests to enforce a relaxed default share expiration date
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Share20/ManagerTest.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 68da78dd8f8..f351412c958 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -833,6 +833,27 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $share->getExpirationDate());
}
+ public function testValidateExpirationDateEnforceRelaxedDefaultButNotSetNewShare() {
+ $share = $this->manager->newShare();
+
+ $this->config->method('getAppValue')
+ ->willReturnMap([
+ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
+ ['core', 'shareapi_expire_after_n_days', '7', '3'],
+ ['core', 'shareapi_default_expire_date', 'no', 'yes'],
+ ['core', 'link_defaultExpDays', 3, '1'],
+ ]);
+
+ $expected = new \DateTime();
+ $expected->setTime(0,0,0);
+ $expected->add(new \DateInterval('P1D'));
+
+ self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+
+ $this->assertNotNull($share->getExpirationDate());
+ $this->assertEquals($expected, $share->getExpirationDate());
+ }
+
public function testValidateExpirationDateEnforceTooFarIntoFuture() {
$future = new \DateTime();
$future->add(new \DateInterval('P7D'));