diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-07-23 16:42:33 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-07-25 13:38:18 +0200 |
commit | ecc1f92bb6c7ac3121c35affad607a344a79ef52 (patch) | |
tree | faf5bb913b3750f809cdd6e7a4ab6f835a2dca6e /tests/lib | |
parent | 9834e3854201d68fbd5dcbef09122c48cc5bcb10 (diff) | |
download | nextcloud-server-ecc1f92bb6c7ac3121c35affad607a344a79ef52.tar.gz nextcloud-server-ecc1f92bb6c7ac3121c35affad607a344a79ef52.zip |
add OCS api call to set expire date for link shares
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/share/share.php | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 5920b44a8e0..0e3dfe8291d 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -326,10 +326,14 @@ class Test_Share extends PHPUnit_Framework_TestCase { $this->shareUserOneTestFileWithUserTwo(); $this->shareUserTestFileAsLink(); - $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast), - 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' - ); + // manipulate share table and set expire date to the past + $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `item_type` = ? AND `item_source` = ? AND `uid_owner` = ? AND `share_type` = ?'); + $query->bindValue(1, new \DateTime($this->dateInPast), 'datetime'); + $query->bindValue(2, 'test'); + $query->bindValue(3, 'test.txt'); + $query->bindValue(4, $this->user1); + $query->bindValue(5, \OCP\Share::SHARE_TYPE_LINK); + $query->execute(); $shares = OCP\Share::getItemsShared('test'); $this->assertSame(1, count($shares)); @@ -337,6 +341,24 @@ class Test_Share extends PHPUnit_Framework_TestCase { $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share['share_type']); } + public function testSetExpireDateInPast() { + OC_User::setUserId($this->user1); + $this->shareUserOneTestFileWithUserTwo(); + $this->shareUserTestFileAsLink(); + + $setExpireDateFailed = false; + try { + $this->assertTrue( + OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast, ''), + 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' + ); + } catch (\Exception $e) { + $setExpireDateFailed = true; + } + + $this->assertTrue($setExpireDateFailed); + } + public function testShareWithUserExpirationValid() { OC_User::setUserId($this->user1); $this->shareUserOneTestFileWithUserTwo(); @@ -344,7 +366,7 @@ class Test_Share extends PHPUnit_Framework_TestCase { $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture), + OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture, ''), 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' ); @@ -552,7 +574,7 @@ class Test_Share extends PHPUnit_Framework_TestCase { // testGetShareByTokenExpirationValid $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture), + OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture, ''), 'Failed asserting that user 1 successfully set a future expiration date for the test.txt share.' ); $row = $this->getShareByValidToken($token); @@ -561,11 +583,15 @@ class Test_Share extends PHPUnit_Framework_TestCase { 'Failed asserting that the returned row has an expiration date.' ); - // testGetShareByTokenExpirationExpired - $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast), - 'Failed asserting that user 1 successfully set a past expiration date for the test.txt share.' - ); + // manipulate share table and set expire date to the past + $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `item_type` = ? AND `item_source` = ? AND `uid_owner` = ? AND `share_type` = ?'); + $query->bindValue(1, new \DateTime($this->dateInPast), 'datetime'); + $query->bindValue(2, 'test'); + $query->bindValue(3, 'test.txt'); + $query->bindValue(4, $this->user1); + $query->bindValue(5, \OCP\Share::SHARE_TYPE_LINK); + $query->execute(); + $this->assertFalse( OCP\Share::getShareByToken($token), 'Failed asserting that an expired share could not be found.' |