. */ abstract class Test_Share_Backend extends UnitTestCase { protected $userBackend; protected $user1; protected $user2; protected $groupBackend; protected $group; protected $itemType; protected $item; public function setUp() { OC_User::clearBackends(); OC_User::useBackend('dummy'); $this->user1 = uniqid('user_'); $this->user2 = uniqid('user_'); OC_User::createUser($this->user1, 'pass1'); OC_User::createUser($this->user2, 'pass2'); OC_Group::clearBackends(); OC_Group::useBackend(new OC_Group_Dummy); $this->group = uniqid('group_'); OC_Group::createGroup($this->group); } public function testShareWithUserNonExistentItem() { $this->assertFalse(OCP\Share::share($this->itemType, uniqid('foobar_'), OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); } public function testShareWithUserItem() { $this->assertTrue(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); } public function testShareWithGroupNonExistentItem() { $this->assertFalse(OCP\Share::share($this->itemType, uniqid('foobar_'), OCP\Share::SHARETYPE_GROUP, $this->group, OCP\Share::PERMISSION_READ)); } public function testShareWithGroupItem() { $this->assertTrue(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_GROUP, $this->group, OCP\Share::PERMISSION_READ)); } public function testShareWithUserAlreadySharedWith() { $this->assertTrue(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); $this->assertFalse(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); } }