summaryrefslogtreecommitdiffstats
path: root/tests/lib/group/manager.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-03-14 13:51:17 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-04-28 13:49:56 +0200
commit45e42c25de5e498197a9aace7161b4f377a8dacc (patch)
treef08d13bc5b8d561659fd6ca50ee70bae640c4956 /tests/lib/group/manager.php
parente27dc5b6f9acd7e8758da66013dd012540618b74 (diff)
downloadnextcloud-server-45e42c25de5e498197a9aace7161b4f377a8dacc.tar.gz
nextcloud-server-45e42c25de5e498197a9aace7161b4f377a8dacc.zip
Group Database backend must not gather user details itself but ask user
backends. This is a port to master from PR #7745 remove OC_GROUP_BACKEND_GET_DISPLAYNAME option for group backends Conflicts: lib/private/group/backend.php LDAP: getDisplayNamesInGroup is not an option for group backends anymore Conflicts: apps/user_ldap/group_ldap.php apps/user_ldap/group_proxy.php clean up group backends Conflicts: lib/private/group/database.php remove now unnecessary test implement getDisplayNames in group manager adjust user manager tests test for group manager's displayNamesInGroup trim must not be used in empty in PHP < 5.5 keep the constant to not provoke PHP warnings Conflicts: lib/private/group/backend.php
Diffstat (limited to 'tests/lib/group/manager.php')
-rw-r--r--tests/lib/group/manager.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php
index a03997c58eb..aa7737b9f2f 100644
--- a/tests/lib/group/manager.php
+++ b/tests/lib/group/manager.php
@@ -343,4 +343,54 @@ class Manager extends \PHPUnit_Framework_TestCase {
$this->assertEquals('group1', $group1->getGID());
$this->assertEquals('group2', $group2->getGID());
}
+
+ public function testDisplayNamesInGroupMultipleUserBackends() {
+ $user1 = new User('user1', null);
+ $user2 = new User('user2', null);
+ $user3 = new User('user3', null);
+ $user4 = new User('user33', null);
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend1
+ */
+ $backend = $this->getMock('\OC_Group_Database');
+ $backend->expects($this->exactly(2))
+ ->method('groupExists')
+ ->with('testgroup')
+ ->will($this->returnValue(true));
+
+ $backend->expects($this->once())
+ ->method('usersInGroup')
+ ->with('testgroup', '', -1, 0)
+ ->will($this->returnValue(array('user2', 'user33')));
+
+ /**
+ * @var \OC\User\Manager $userManager
+ */
+ $userManager = $this->getMock('\OC\User\Manager');
+ $userManager->expects($this->once())
+ ->method('search')
+ ->with('user3')
+ ->will($this->returnValue(array('user3' => $user3, 'user33' => $user4)));
+
+ $userManager->expects($this->any())
+ ->method('get')
+ ->will($this->returnCallback(function($uid) {
+ switch($uid) {
+ case 'user1' : return new User('user1', null);
+ case 'user2' : return new User('user2', null);
+ case 'user3' : return new User('user3', null);
+ case 'user33': return new User('user33', null);
+ default:
+ return null;
+ }
+ }));
+
+ $manager = new \OC\Group\Manager($userManager);
+ $manager->addBackend($backend);
+
+ $users = $manager->displayNamesInGroup('testgroup', 'user3');
+ $this->assertEquals(1, count($users));
+ $this->assertTrue(isset($users['user33']));
+ }
}