diff options
Diffstat (limited to 'apps/user_ldap/tests/group_ldap.php')
-rw-r--r-- | apps/user_ldap/tests/group_ldap.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index b29449d286e..b18ebb50efa 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -313,4 +313,74 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase { $this->assertSame(2, count($groups)); } + /** + * tests that a user listing is complete, if all it's members have the group + * as their primary. + */ + public function testUsersInGroupPrimaryMembersOnly() { + $access = $this->getAccessMock(); + $this->enableGroups($access); + + $access->connection->expects($this->any()) + ->method('getFromCache') + ->will($this->returnValue(null)); + + $access->expects($this->any()) + ->method('readAttribute') + ->will($this->returnCallback(function($dn, $attr) { + if($attr === 'primaryGroupToken') { + return array(1337); + } + return array(); + })); + + $access->expects($this->any()) + ->method('groupname2dn') + ->will($this->returnValue('cn=foobar,dc=foo,dc=bar')); + + $access->expects($this->once()) + ->method('ownCloudUserNames') + ->will($this->returnValue(array('lisa', 'bart', 'kira', 'brad'))); + + $groupBackend = new GroupLDAP($access); + $users = $groupBackend->usersInGroup('foobar'); + + $this->assertSame(4, count($users)); + } + + /** + * tests that a user counting is complete, if all it's members have the group + * as their primary. + */ + public function testCountUsersInGroupPrimaryMembersOnly() { + $access = $this->getAccessMock(); + $this->enableGroups($access); + + $access->connection->expects($this->any()) + ->method('getFromCache') + ->will($this->returnValue(null)); + + $access->expects($this->any()) + ->method('readAttribute') + ->will($this->returnCallback(function($dn, $attr) { + if($attr === 'primaryGroupToken') { + return array(1337); + } + return array(); + })); + + $access->expects($this->any()) + ->method('groupname2dn') + ->will($this->returnValue('cn=foobar,dc=foo,dc=bar')); + + $access->expects($this->once()) + ->method('countUsers') + ->will($this->returnValue(4)); + + $groupBackend = new GroupLDAP($access); + $users = $groupBackend->countUsersInGroup('foobar'); + + $this->assertSame(4, $users); + } + } |