summaryrefslogtreecommitdiffstats
path: root/tests/lib/share
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-09-05 02:31:54 +0200
committerAndreas Fischer <bantu@owncloud.com>2013-09-12 23:43:20 +0200
commitcf97eac4010a19b1d9baba02970f825c157fbabe (patch)
treecfa27518355590e6988ed0f76d3a4aae5d5a9980 /tests/lib/share
parente4b334c3f199b210fbd18b619f65cac44795dd7c (diff)
downloadnextcloud-server-cf97eac4010a19b1d9baba02970f825c157fbabe.tar.gz
nextcloud-server-cf97eac4010a19b1d9baba02970f825c157fbabe.zip
Do not repeat shareUserOneTestFileWithUserTwo() code.
Diffstat (limited to 'tests/lib/share')
-rw-r--r--tests/lib/share/share.php47
1 files changed, 22 insertions, 25 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index c82ede2f387..af69c68c196 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -124,6 +124,27 @@ class Test_Share extends PHPUnit_Framework_TestCase {
}
}
+ protected function shareUserOneTestFileWithUserTwo()
+ {
+ OC_User::setUserId($this->user1);
+ $this->assertTrue(
+ OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ),
+ 'Failed asserting that user 1 successfully shared text.txt with user 2.'
+ );
+ $this->assertEquals(
+ array('test.txt'),
+ OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ 'Failed asserting that test.txt is a shared file of user 1.'
+ );
+
+ OC_User::setUserId($this->user2);
+ $this->assertEquals(
+ array('test.txt'),
+ OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+ 'Failed asserting that user 2 has access to test.txt after initial sharing.'
+ );
+ }
+
public function testShareWithUser() {
// Invalid shares
$message = 'Sharing test.txt failed, because the user '.$this->user1.' is the item owner';
@@ -149,10 +170,7 @@ class Test_Share extends PHPUnit_Framework_TestCase {
}
// Valid share
- $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ));
- $this->assertEquals(array('test.txt'), OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE));
- OC_User::setUserId($this->user2);
- $this->assertEquals(array('test.txt'), OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE));
+ $this->shareUserOneTestFileWithUserTwo();
// Attempt to share again
OC_User::setUserId($this->user1);
@@ -302,27 +320,6 @@ class Test_Share extends PHPUnit_Framework_TestCase {
);
}
- protected function shareUserOneTestFileWithUserTwo()
- {
- OC_User::setUserId($this->user1);
- $this->assertTrue(
- OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ),
- 'Failed asserting that user 1 successfully shared text.txt with user 2.'
- );
- $this->assertEquals(
- array('test.txt'),
- OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that test.txt is a shared file of user 1.'
- );
-
- OC_User::setUserId($this->user2);
- $this->assertEquals(
- array('test.txt'),
- OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
- 'Failed asserting that user 2 has access to test.txt after initial sharing.'
- );
- }
-
public function testShareWithGroup() {
// Invalid shares
$message = 'Sharing test.txt failed, because the group foobar does not exist';