summaryrefslogtreecommitdiffstats
path: root/tests/lib/share20
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-25 14:21:46 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-02-25 14:21:46 +0100
commit6d4f80d680bfd45293a055b1c2502f512cbf1070 (patch)
tree1b102d4c46211bd701cc5b03db0c4d55714f9431 /tests/lib/share20
parent32f4bea0ae174487fd5a58e2c9eeb6e567d1ff91 (diff)
downloadnextcloud-server-6d4f80d680bfd45293a055b1c2502f512cbf1070.tar.gz
nextcloud-server-6d4f80d680bfd45293a055b1c2502f512cbf1070.zip
Set default expiration date if none given on share creation
When we create a share for the first time we should set the default expiration date. If none is given. Fixes #22642
Diffstat (limited to 'tests/lib/share20')
-rw-r--r--tests/lib/share20/managertest.php33
1 files changed, 27 insertions, 6 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index c41f0754396..579a099233b 100644
--- a/tests/lib/share20/managertest.php
+++ b/tests/lib/share20/managertest.php
@@ -713,6 +713,7 @@ class ManagerTest extends \Test\TestCase {
*/
public function testvalidateExpirationDateEnforceButNotSet() {
$share = $this->manager->newShare();
+ $share->setProviderId('foo')->setId('bar');
$this->config->method('getAppValue')
->will($this->returnValueMap([
@@ -722,6 +723,26 @@ class ManagerTest extends \Test\TestCase {
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
}
+ public function testvalidateExpirationDateEnforceButNotSetNewShare() {
+ $share = $this->manager->newShare();
+
+ $this->config->method('getAppValue')
+ ->will($this->returnValueMap([
+ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
+ ['core', 'shareapi_expire_after_n_days', '7', '3'],
+ ['core', 'shareapi_default_expire_date', 'no', 'yes'],
+ ]));
+
+ $expected = new \DateTime();
+ $expected->setTime(0,0,0);
+ $expected->add(new \DateInterval('P3D'));
+
+ $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+
+ $this->assertNotNull($share->getExpirationDate());
+ $this->assertEquals($expected, $share->getExpirationDate());
+ }
+
public function testvalidateExpirationDateEnforceToFarIntoFuture() {
// Expire date in the past
$future = new \DateTime();
@@ -769,9 +790,9 @@ class ManagerTest extends \Test\TestCase {
return $data['expirationDate'] == $future;
}));
- $future = $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+ $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
- $this->assertEquals($expected, $future);
+ $this->assertEquals($expected, $share->getExpirationDate());
}
public function testvalidateExpirationDateNoDateNoDefaultNull() {
@@ -790,9 +811,9 @@ class ManagerTest extends \Test\TestCase {
return $data['expirationDate'] == $expected;
}));
- $res = $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+ $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
- $this->assertEquals($expected, $res);
+ $this->assertEquals($expected, $share->getExpirationDate());
}
public function testvalidateExpirationDateNoDateNoDefault() {
@@ -804,9 +825,9 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
- $date = $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+ $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
- $this->assertNull($date);
+ $this->assertNull($share->getExpirationDate());
}
public function testvalidateExpirationDateNoDateDefault() {