diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-03-16 14:46:44 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-05-23 19:10:11 +0200 |
commit | c5042f15453cff57c49444929bad64b445be7def (patch) | |
tree | a9f660cebc992644a510372712990527d794f11e /apps | |
parent | e11a523ce9c8920ae1e3bb1509f232af03e69562 (diff) | |
download | nextcloud-server-c5042f15453cff57c49444929bad64b445be7def.tar.gz nextcloud-server-c5042f15453cff57c49444929bad64b445be7def.zip |
Use node api
* delete old test that can't happen anymore since we check for a valid
node
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php index 246fe816e54..a20c66a39bd 100644 --- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php +++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php @@ -129,17 +129,20 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase { public function testClearShares() { $this->loginAsUser($this->user1); - $view = new \OC\Files\View('/' . $this->user1 . '/'); - $view->mkdir('files/test'); - $view->mkdir('files/test/sub'); + $user1Folder = \OC::$server->getUserFolder($this->user1); + $testFolder = $user1Folder->newFolder('test'); + $testSubFolder = $testFolder->newFolder('sub'); - $fileInfo = $view->getFileInfo('files/test/sub'); - $fileId = $fileInfo->getId(); + $shareManager = \OC::$server->getShareManager(); + $share = $shareManager->newShare(); - $this->assertTrue( - \OC\Share\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), - 'Failed asserting that user 1 successfully shared "test/sub" with user 2.' - ); + $share->setNode($testSubFolder) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setPermissions(\OCP\Constants::PERMISSION_READ) + ->setSharedWith($this->user2) + ->setSharedBy($this->user1); + + $shareManager->createShare($share); $this->assertCount(1, $this->getShares()); @@ -147,28 +150,11 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase { $this->assertCount(1, $this->getShares(), 'Linked shares not deleted'); - $view->unlink('files/test'); + $testFolder->delete(); $this->job->run([]); $this->assertCount(0, $this->getShares(), 'Orphaned shares deleted'); } - - public function testKeepNonFileShares() { - $this->loginAsUser($this->user1); - - \OC\Share\Share::registerBackend('test', 'Test\Share\Backend'); - - $this->assertTrue( - \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), - 'Failed asserting that user 1 successfully shared something with user 2.' - ); - - $this->assertCount(1, $this->getShares()); - - $this->job->run([]); - - $this->assertCount(1, $this->getShares(), 'Non-file shares kept'); - } } |