diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-04-15 09:02:17 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-04-19 14:04:00 +0200 |
commit | 92abb5f23d3beb7e60c9f3a656a7ca41b5812da7 (patch) | |
tree | 91328abd44d8729396c7e454ddb71b2c1e74201c /apps/files_versions/tests | |
parent | afa37d363fe1bedfe85a4dbd53adb091f3b014b2 (diff) | |
download | nextcloud-server-92abb5f23d3beb7e60c9f3a656a7ca41b5812da7.tar.gz nextcloud-server-92abb5f23d3beb7e60c9f3a656a7ca41b5812da7.zip |
Fix tests
Diffstat (limited to 'apps/files_versions/tests')
-rw-r--r-- | apps/files_versions/tests/versions.php | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php index 9d0ffb87946..b8e68cfadf7 100644 --- a/apps/files_versions/tests/versions.php +++ b/apps/files_versions/tests/versions.php @@ -297,8 +297,6 @@ class Test_Files_Versioning extends \Test\TestCase { \OC\Files\Filesystem::mkdir('folder1/folder2'); \OC\Files\Filesystem::file_put_contents("folder1/test.txt", "test file"); - $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1'); - $t1 = time(); // second version is two weeks older, this way we make sure that no // version will be expired @@ -314,7 +312,14 @@ class Test_Files_Versioning extends \Test\TestCase { $this->rootView->file_put_contents($v1, 'version1'); $this->rootView->file_put_contents($v2, 'version2'); - \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL); + $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); + $share = \OC::$server->getShareManager()->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedBy(self::TEST_VERSIONS_USER) + ->setSharedWith(self::TEST_VERSIONS_USER2) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $share = \OC::$server->getShareManager()->createShare($share); self::loginHelper(self::TEST_VERSIONS_USER2); @@ -332,6 +337,8 @@ class Test_Files_Versioning extends \Test\TestCase { $this->assertTrue($this->rootView->file_exists($v1Renamed)); $this->assertTrue($this->rootView->file_exists($v2Renamed)); + + \OC::$server->getShareManager()->deleteShare($share); } public function testMoveFolder() { @@ -373,13 +380,14 @@ class Test_Files_Versioning extends \Test\TestCase { \OC\Files\Filesystem::mkdir('folder1'); $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1'); - \OCP\Share::shareItem( - 'folder', - $fileInfo['fileid'], - \OCP\Share::SHARE_TYPE_USER, - self::TEST_VERSIONS_USER2, - \OCP\Constants::PERMISSION_ALL - ); + $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); + $share = \OC::$server->getShareManager()->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedBy(self::TEST_VERSIONS_USER) + ->setSharedWith(self::TEST_VERSIONS_USER2) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $share = \OC::$server->getShareManager()->createShare($share); self::loginHelper(self::TEST_VERSIONS_USER2); $versionsFolder2 = '/' . self::TEST_VERSIONS_USER2 . '/files_versions'; @@ -413,20 +421,22 @@ class Test_Files_Versioning extends \Test\TestCase { $this->assertTrue($this->rootView->file_exists($v1Renamed)); $this->assertTrue($this->rootView->file_exists($v2Renamed)); + + \OC::$server->getShareManager()->deleteShare($share); } public function testMoveFolderIntoSharedFolderAsRecipient() { \OC\Files\Filesystem::mkdir('folder1'); - $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1'); - \OCP\Share::shareItem( - 'folder', - $fileInfo['fileid'], - \OCP\Share::SHARE_TYPE_USER, - self::TEST_VERSIONS_USER2, - \OCP\Constants::PERMISSION_ALL - ); + $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); + $share = \OC::$server->getShareManager()->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedBy(self::TEST_VERSIONS_USER) + ->setSharedWith(self::TEST_VERSIONS_USER2) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $share = \OC::$server->getShareManager()->createShare($share); self::loginHelper(self::TEST_VERSIONS_USER2); $versionsFolder2 = '/' . self::TEST_VERSIONS_USER2 . '/files_versions'; @@ -462,14 +472,14 @@ class Test_Files_Versioning extends \Test\TestCase { $this->assertTrue($this->rootView->file_exists($v1Renamed)); $this->assertTrue($this->rootView->file_exists($v2Renamed)); + + \OC::$server->getShareManager()->deleteShare($share); } public function testRenameSharedFile() { \OC\Files\Filesystem::file_put_contents("test.txt", "test file"); - $fileInfo = \OC\Files\Filesystem::getFileInfo('test.txt'); - $t1 = time(); // second version is two weeks older, this way we make sure that no // version will be expired @@ -486,7 +496,14 @@ class Test_Files_Versioning extends \Test\TestCase { $this->rootView->file_put_contents($v1, 'version1'); $this->rootView->file_put_contents($v2, 'version2'); - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL); + $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('test.txt'); + $share = \OC::$server->getShareManager()->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedBy(self::TEST_VERSIONS_USER) + ->setSharedWith(self::TEST_VERSIONS_USER2) + ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); + $share = \OC::$server->getShareManager()->createShare($share); self::loginHelper(self::TEST_VERSIONS_USER2); @@ -504,6 +521,8 @@ class Test_Files_Versioning extends \Test\TestCase { $this->assertFalse($this->rootView->file_exists($v1Renamed)); $this->assertFalse($this->rootView->file_exists($v2Renamed)); + + \OC::$server->getShareManager()->deleteShare($share); } public function testCopy() { @@ -744,15 +763,15 @@ class Test_Files_Versioning extends \Test\TestCase { \OC\Files\Filesystem::mkdir('folder'); \OC\Files\Filesystem::file_put_contents('folder/test.txt', 'test file'); - $fileInfo = \OC\Files\Filesystem::getFileInfo('folder'); - - \OCP\Share::shareItem( - 'folder', - $fileInfo['fileid'], - \OCP\Share::SHARE_TYPE_USER, - self::TEST_VERSIONS_USER2, - \OCP\Constants::PERMISSION_ALL - ); + + $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder'); + $share = \OC::$server->getShareManager()->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedBy(self::TEST_VERSIONS_USER) + ->setSharedWith(self::TEST_VERSIONS_USER2) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $share = \OC::$server->getShareManager()->createShare($share); $this->loginAsUser(self::TEST_VERSIONS_USER2); @@ -760,6 +779,8 @@ class Test_Files_Versioning extends \Test\TestCase { \OC\Files\Filesystem::getView(), 'folder/test.txt' ); + + \OC::$server->getShareManager()->deleteShare($share); } /** |