aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:48:21 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:48:21 +0100
commit0795cc373d667dbd515d7631131eebb1be47324c (patch)
tree9290312449f5e70515321397a8cc39486438683e /tests
parent66536f912ebe7b2287dad839ffac66f949c1bf41 (diff)
parent6d4f80d680bfd45293a055b1c2502f512cbf1070 (diff)
downloadnextcloud-server-0795cc373d667dbd515d7631131eebb1be47324c.tar.gz
nextcloud-server-0795cc373d667dbd515d7631131eebb1be47324c.zip
Merge pull request #22646 from owncloud/fix_22642
Set default expiration date if none given on share creation
Diffstat (limited to 'tests')
-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 42610f94715..22ca41cb501 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 && $data['passwordSet'] === false;
}));
- $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() {
@@ -805,9 +826,9 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setPassword('password');
- $date = $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+ $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
- $this->assertNull($date);
+ $this->assertNull($share->getExpirationDate());
}
public function testvalidateExpirationDateNoDateDefault() {