Esempio n. 1
0
 public function testShareTags()
 {
     $testTag = 'TestTag';
     OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $tagger = $this->tagMgr->load('test');
     $tagger->tagAs(1, $testTag);
     $otherUserId = $this->getUniqueID('user2_');
     OC_User::createUser($otherUserId, 'pass');
     OC_User::setUserId($otherUserId);
     $otherUserSession = $this->getMock('\\OCP\\IUserSession');
     $otherUserSession->expects($this->any())->method('getUser')->will($this->returnValue(new OC\User\User($otherUserId, null)));
     $otherTagMgr = new OC\TagManager($this->tagMapper, $otherUserSession);
     $otherTagger = $otherTagMgr->load('test');
     $this->assertFalse($otherTagger->hasTag($testTag));
     OC_User::setUserId($this->user->getUID());
     OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
     OC_User::setUserId($otherUserId);
     $otherTagger = $otherTagMgr->load('test', array(), true);
     // Update tags, load shared ones.
     $this->assertTrue($otherTagger->hasTag($testTag));
     $this->assertContains(1, $otherTagger->getIdsForTag($testTag));
 }
Esempio n. 2
0
 public function testShareTags()
 {
     $test_tag = 'TestTag';
     OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $tagger = $this->tagMgr->load('test');
     $tagger->tagAs(1, $test_tag);
     $other_user = uniqid('user2_');
     OC_User::createUser($other_user, 'pass');
     OC_User::setUserId($other_user);
     $other_tagMgr = new OC\TagManager($this->tagMapper, $other_user);
     $other_tagger = $other_tagMgr->load('test');
     $this->assertFalse($other_tagger->hasTag($test_tag));
     OC_User::setUserId($this->user);
     OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $other_user, OCP\PERMISSION_READ);
     OC_User::setUserId($other_user);
     $other_tagger = $other_tagMgr->load('test', array(), true);
     // Update tags, load shared ones.
     $this->assertTrue($other_tagger->hasTag($test_tag));
     $this->assertContains(1, $other_tagger->getIdsForTag($test_tag));
 }