summaryrefslogtreecommitdiffstats
path: root/tests/lib/Group
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-12-22 20:53:52 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-12-22 21:21:16 +0100
commit91a1e5fd9d939c69ccacacd44001d52453957093 (patch)
tree562acec299931122bc7585ba4017532e32e04268 /tests/lib/Group
parentb4d779977a9b9a15b7268ad68a897735f9607dc5 (diff)
downloadnextcloud-server-91a1e5fd9d939c69ccacacd44001d52453957093.tar.gz
nextcloud-server-91a1e5fd9d939c69ccacacd44001d52453957093.zip
fix more tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests/lib/Group')
-rw-r--r--tests/lib/Group/ManagerTest.php46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php
index 93fe67ad9bb..1a7ced5f1ba 100644
--- a/tests/lib/Group/ManagerTest.php
+++ b/tests/lib/Group/ManagerTest.php
@@ -22,10 +22,20 @@
*/
namespace Test\Group;
+use OC\User\Manager;
use OCP\IUser;
use OCP\GroupInterface;
class ManagerTest extends \Test\TestCase {
+ /** @var Manager|\PHPUnit_Framework_MockObject_MockObject $userManager */
+ protected $userManager;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->userManager = $this->createMock(Manager::class);
+ }
+
private function getTestUser($userId) {
$mockUser = $this->createMock(IUser::class);
$mockUser->expects($this->any())
@@ -306,9 +316,6 @@ class ManagerTest extends \Test\TestCase {
->with('group1')
->will($this->returnValue(true));
- $userBackend = $this->getMockBuilder('\OC\Group\Database')
- ->disableOriginalConstructor()
- ->getMock();
$manager = new \OC\Group\Manager($this->userManager);
$manager->addBackend($backend);
@@ -426,9 +433,6 @@ class ManagerTest extends \Test\TestCase {
->method('groupExists')
->will($this->returnValue(true));
- $userBackend = $this->getMockBuilder('\OC\User\Backend')
- ->disableOriginalConstructor()
- ->getMock();
$manager = new \OC\Group\Manager($this->userManager);
$manager->addBackend($backend1);
$manager->addBackend($backend2);
@@ -477,8 +481,8 @@ class ManagerTest extends \Test\TestCase {
'user33' => $this->getTestUser('user33')];
case 2 : return [];
}
+ return null;
}));
-
$this->userManager->expects($this->any())
->method('get')
->will($this->returnCallback(function($uid) use ($userBackend) {
@@ -540,8 +544,8 @@ class ManagerTest extends \Test\TestCase {
'user33' => $this->getTestUser('user33')];
case 2 : return ['user333' => $this->getTestUser('user333')];
}
+ return null;
}));
-
$this->userManager->expects($this->any())
->method('get')
->will($this->returnCallback(function($uid) use ($userBackend) {
@@ -600,16 +604,16 @@ class ManagerTest extends \Test\TestCase {
->method('searchDisplayName')
->with('user3')
->will($this->returnCallback(function($search, $limit, $offset) use ($userBackend) {
- switch($offset) {
- case 0 :
- return [
- 'user3' => $this->getTestUser('user3'),
- 'user33' => $this->getTestUser('user33'),
- 'user333' => $this->getTestUser('user333')
- ];
- }
+ switch($offset) {
+ case 0 :
+ return [
+ 'user3' => $this->getTestUser('user3'),
+ 'user33' => $this->getTestUser('user33'),
+ 'user333' => $this->getTestUser('user333')
+ ];
+ }
+ return null;
}));
-
$this->userManager->expects($this->any())
->method('get')
->will($this->returnCallback(function($uid) use ($userBackend) {
@@ -793,7 +797,7 @@ class ManagerTest extends \Test\TestCase {
// add user
$group = $manager->get('group1');
$group->addUser($user1);
- $expectedGroups = array('group1');
+ $expectedGroups = ['group1'];
// check result
$groups = $manager->getUserGroups($user1);
@@ -881,11 +885,7 @@ class ManagerTest extends \Test\TestCase {
['group2', ['gid' => 'group2']],
]));
- /**
- * @var \OC\User\Manager $userManager
- */
- $userManager = $this->createMock('\OC\User\Manager');
- $manager = new \OC\Group\Manager($userManager);
+ $manager = new \OC\Group\Manager($this->userManager);
$manager->addBackend($backend);
// group with display name