/**
  * @dataProvider visibilityCheckProvider
  */
 public function testVisibilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult)
 {
     $user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
     $user->expects($this->any())->method('getUID')->will($this->returnValue('test'));
     $tag1 = $this->tagManager->createTag('one', $userVisible, $userAssignable);
     $this->groupManager->expects($this->any())->method('isAdmin')->with('test')->will($this->returnValue($isAdmin));
     $this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1, $user));
 }
 /**
  * Delete tag to object association
  */
 public function delete()
 {
     try {
         if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
             throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
         }
         if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) {
             throw new Forbidden('No permission to unassign tag ' . $this->tag->getId());
         }
         $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId());
     } catch (TagNotFoundException $e) {
         // can happen if concurrent deletion occurred
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
     }
 }
 /**
  * @param string $name
  */
 function childExists($name)
 {
     try {
         $tag = $this->tagManager->getTagsByIds([$name]);
         $tag = current($tag);
         if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
             return false;
         }
         return true;
     } catch (\InvalidArgumentException $e) {
         throw new BadRequest('Invalid tag id', 0, $e);
     } catch (TagNotFoundException $e) {
         return false;
     }
 }
 function childExists($tagId)
 {
     try {
         $result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
         if ($result) {
             $tags = $this->tagManager->getTagsByIds([$tagId]);
             $tag = current($tags);
             if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
                 return false;
             }
         }
         return $result;
     } catch (\InvalidArgumentException $e) {
         throw new BadRequest('Invalid tag id', 0, $e);
     } catch (TagNotFoundException $e) {
         return false;
     }
 }