summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-04-27 15:24:28 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-20 17:56:02 +0200
commit09b3883d9ceae77793e524209090f2e36ab61260 (patch)
treea85b527783e3df487900b43ae9fb86018d695750 /tests
parent8343cfb64b8297035987bc4980ec72015c8e1a04 (diff)
downloadnextcloud-server-09b3883d9ceae77793e524209090f2e36ab61260.tar.gz
nextcloud-server-09b3883d9ceae77793e524209090f2e36ab61260.zip
Updated canUser* functions in SystemTagManager to accept objects
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/SystemTag/SystemTagManagerTest.php44
1 files changed, 15 insertions, 29 deletions
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php
index 9bd4622c2be..fa13d287ed7 100644
--- a/tests/lib/SystemTag/SystemTagManagerTest.php
+++ b/tests/lib/SystemTag/SystemTagManagerTest.php
@@ -44,11 +44,6 @@ class SystemTagManagerTest extends TestCase {
private $groupManager;
/**
- * @var IUserManager
- */
- private $userManager;
-
- /**
* @var EventDispatcherInterface
*/
private $dispatcher;
@@ -61,15 +56,10 @@ class SystemTagManagerTest extends TestCase {
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')
->getMock();
- $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
$this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')->getMock();
- $this->groupManager->expects($this->any())
- ->method('isAdmin')
- ->will($this->returnValue(false));
$this->tagManager = new SystemTagManager(
$this->connection,
- $this->userManager,
$this->groupManager,
$this->dispatcher
);
@@ -443,20 +433,18 @@ class SystemTagManagerTest extends TestCase {
* @dataProvider visibilityCheckProvider
*/
public function testVisibilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult) {
- $userId = 'test';
+ $user = $this->getMockBuilder('\OCP\IUser')->getMock();
+ $user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('test'));
$tag1 = $this->tagManager->createTag('one', $userVisible, $userAssignable);
- $this->userManager->expects($this->once())
- ->method('get')
- ->with($userId)
- ->will($this->returnValue([]));
- $this->groupManager->expects($this->once())
+ $this->groupManager->expects($this->any())
->method('isAdmin')
- ->with($userId)
+ ->with('test')
->will($this->returnValue($isAdmin));
- $this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1, $userID));
- $this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1->getId(), $userID));
+ $this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1, $user));
}
public function assignabilityCheckProvider() {
@@ -475,21 +463,19 @@ class SystemTagManagerTest extends TestCase {
/**
* @dataProvider assignabilityCheckProvider
*/
- public function testVisibilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult) {
- $userId = 'test';
+ public function testAssignabilityCheck($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->userManager->expects($this->once())
- ->method('get')
- ->with($userId)
- ->will($this->returnValue([]));
- $this->groupManager->expects($this->once())
+ $this->groupManager->expects($this->any())
->method('isAdmin')
- ->with($userId)
+ ->with('test')
->will($this->returnValue($isAdmin));
- $this->assertEquals($expectedResult, $this->tagManager->canUserAssignTag($tag1, $userID));
- $this->assertEquals($expectedResult, $this->tagManager->canUserAssignTag($tag1->getId(), $userID));
+ $this->assertEquals($expectedResult, $this->tagManager->canUserAssignTag($tag1, $user));
}
/**