summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-11-12 09:35:34 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-11-16 13:16:55 +0000
commit731cce45426806134a61c922166826fb017f189a (patch)
treebe9f8b8f8e537f94301bec296e11d8de3170bad3
parent115a988cd29fcc0d0e629bd815096614d48bf269 (diff)
downloadnextcloud-server-731cce45426806134a61c922166826fb017f189a.tar.gz
nextcloud-server-731cce45426806134a61c922166826fb017f189a.zip
Add unit test for expiration date with date and with default
This adds back what was being actually tested in the unit test fixed in the previous commit. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r--tests/lib/Share20/ManagerTest.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index ad2f536f6da..a4647cfb9c6 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -961,6 +961,34 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $share->getExpirationDate());
}
+ public function testValidateExpirationDateDefault() {
+ $future = new \DateTime();
+ $future->add(new \DateInterval('P5D'));
+ $future->setTime(0,0,0);
+
+ $expected = clone $future;
+
+ $share = $this->manager->newShare();
+ $share->setExpirationDate($future);
+
+ $this->config->method('getAppValue')
+ ->willReturnMap([
+ ['core', 'shareapi_default_expire_date', 'no', 'yes'],
+ ['core', 'shareapi_expire_after_n_days', '7', '3'],
+ ['core', 'link_defaultExpDays', 3, '1'],
+ ]);
+
+ $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ $hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
+ return $data['expirationDate'] == $expected;
+ }));
+
+ self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+
+ $this->assertEquals($expected, $share->getExpirationDate());
+ }
+
public function testValidateExpirationDateHookModification() {
$nextWeek = new \DateTime();
$nextWeek->add(new \DateInterval('P7D'));