summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-03-16 14:59:11 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-05-23 19:12:02 +0200
commit33b639d23c6d93519a6541161939e81ca5703720 (patch)
tree05741eeac928893287c43c84125628181179a8c7 /apps
parentc5042f15453cff57c49444929bad64b445be7def (diff)
downloadnextcloud-server-33b639d23c6d93519a6541161939e81ca5703720.tar.gz
nextcloud-server-33b639d23c6d93519a6541161939e81ca5703720.zip
Fix ExpiresSharesJobTest
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/tests/ExpireSharesJobTest.php37
1 files changed, 21 insertions, 16 deletions
diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php
index 46b50c5fac4..84449048ef3 100644
--- a/apps/files_sharing/tests/ExpireSharesJobTest.php
+++ b/apps/files_sharing/tests/ExpireSharesJobTest.php
@@ -133,15 +133,18 @@ class ExpireSharesJobTest extends \Test\TestCase {
public function testExpireLinkShare($addExpiration, $interval, $addInterval, $shouldExpire) {
$this->loginAsUser($this->user1);
- $view = new \OC\Files\View('/' . $this->user1 . '/');
- $view->mkdir('files/test');
+ $user1Folder = \OC::$server->getUserFolder($this->user1);
+ $testFolder = $user1Folder->newFolder('test');
- $fileInfo = $view->getFileInfo('files/test');
+ $shareManager = \OC::$server->getShareManager();
+ $share = $shareManager->newShare();
- $this->assertNotNull(
- \OC\Share\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ),
- 'Failed asserting that user 1 successfully shared "test" by link.'
- );
+ $share->setNode($testFolder)
+ ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setSharedBy($this->user1);
+
+ $shareManager->createShare($share);
$shares = $this->getShares();
$this->assertCount(1, $shares);
@@ -187,20 +190,22 @@ class ExpireSharesJobTest extends \Test\TestCase {
public function testDoNotExpireOtherShares() {
$this->loginAsUser($this->user1);
- $view = new \OC\Files\View('/' . $this->user1 . '/');
- $view->mkdir('files/test');
+ $user1Folder = \OC::$server->getUserFolder($this->user1);
+ $testFolder = $user1Folder->newFolder('test');
+
+ $shareManager = \OC::$server->getShareManager();
+ $share = $shareManager->newShare();
- $fileInfo = $view->getFileInfo('files/test');
+ $share->setNode($testFolder)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setSharedBy($this->user1)
+ ->setSharedWith($this->user2);
- $this->assertNotNull(
- \OC\Share\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ),
- 'Failed asserting that user 1 successfully shared "test" by link with user2.'
- );
+ $shareManager->createShare($share);
$shares = $this->getShares();
$this->assertCount(1, $shares);
- reset($shares);
- $share = current($shares);
$this->logout();