php-cs happyness
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
e9e61b9537
commit
af6b0ecec0
|
@ -50,6 +50,47 @@ use Test\TestCase;
|
||||||
* @package OCA\User_LDAP\Tests
|
* @package OCA\User_LDAP\Tests
|
||||||
*/
|
*/
|
||||||
class Group_LDAPTest extends TestCase {
|
class Group_LDAPTest extends TestCase {
|
||||||
|
public function testCountEmptySearchString() {
|
||||||
|
$access = $this->getAccessMock();
|
||||||
|
$pluginManager = $this->getPluginManagerMock();
|
||||||
|
$groupDN = 'cn=group,dc=foo,dc=bar';
|
||||||
|
|
||||||
|
$this->enableGroups($access);
|
||||||
|
|
||||||
|
$access->expects($this->any())
|
||||||
|
->method('groupname2dn')
|
||||||
|
->willReturn($groupDN);
|
||||||
|
$access->expects($this->any())
|
||||||
|
->method('readAttribute')
|
||||||
|
->willReturnCallback(function ($dn) use ($groupDN) {
|
||||||
|
if ($dn === $groupDN) {
|
||||||
|
return [
|
||||||
|
'uid=u11,ou=users,dc=foo,dc=bar',
|
||||||
|
'uid=u22,ou=users,dc=foo,dc=bar',
|
||||||
|
'uid=u33,ou=users,dc=foo,dc=bar',
|
||||||
|
'uid=u34,ou=users,dc=foo,dc=bar'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
$access->expects($this->any())
|
||||||
|
->method('isDNPartOfBase')
|
||||||
|
->willReturn(true);
|
||||||
|
// for primary groups
|
||||||
|
$access->expects($this->once())
|
||||||
|
->method('countUsers')
|
||||||
|
->willReturn(2);
|
||||||
|
|
||||||
|
$access->userManager->expects($this->any())
|
||||||
|
->method('getAttributes')
|
||||||
|
->willReturn(['displayName', 'mail']);
|
||||||
|
|
||||||
|
$groupBackend = new GroupLDAP($access, $pluginManager);
|
||||||
|
$users = $groupBackend->countUsersInGroup('group');
|
||||||
|
|
||||||
|
$this->assertSame(6, $users);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return MockObject|Access
|
* @return MockObject|Access
|
||||||
*/
|
*/
|
||||||
|
@ -98,47 +139,6 @@ class Group_LDAPTest extends TestCase {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCountEmptySearchString() {
|
|
||||||
$access = $this->getAccessMock();
|
|
||||||
$pluginManager = $this->getPluginManagerMock();
|
|
||||||
$groupDN = 'cn=group,dc=foo,dc=bar';
|
|
||||||
|
|
||||||
$this->enableGroups($access);
|
|
||||||
|
|
||||||
$access->expects($this->any())
|
|
||||||
->method('groupname2dn')
|
|
||||||
->willReturn($groupDN);
|
|
||||||
$access->expects($this->any())
|
|
||||||
->method('readAttribute')
|
|
||||||
->willReturnCallback(function ($dn) use ($groupDN) {
|
|
||||||
if ($dn === $groupDN) {
|
|
||||||
return [
|
|
||||||
'uid=u11,ou=users,dc=foo,dc=bar',
|
|
||||||
'uid=u22,ou=users,dc=foo,dc=bar',
|
|
||||||
'uid=u33,ou=users,dc=foo,dc=bar',
|
|
||||||
'uid=u34,ou=users,dc=foo,dc=bar'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
$access->expects($this->any())
|
|
||||||
->method('isDNPartOfBase')
|
|
||||||
->willReturn(true);
|
|
||||||
// for primary groups
|
|
||||||
$access->expects($this->once())
|
|
||||||
->method('countUsers')
|
|
||||||
->willReturn(2);
|
|
||||||
|
|
||||||
$access->userManager->expects($this->any())
|
|
||||||
->method('getAttributes')
|
|
||||||
->willReturn(['displayName', 'mail']);
|
|
||||||
|
|
||||||
$groupBackend = new GroupLDAP($access, $pluginManager);
|
|
||||||
$users = $groupBackend->countUsersInGroup('group');
|
|
||||||
|
|
||||||
$this->assertSame(6, $users);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCountWithSearchString() {
|
public function testCountWithSearchString() {
|
||||||
$access = $this->getAccessMock();
|
$access = $this->getAccessMock();
|
||||||
$pluginManager = $this->getPluginManagerMock();
|
$pluginManager = $this->getPluginManagerMock();
|
||||||
|
@ -503,7 +503,7 @@ class Group_LDAPTest extends TestCase {
|
||||||
$groupBackend->inGroup($uid, $gid);
|
$groupBackend->inGroup($uid, $gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function groupWithMembersProvider() {
|
public function groupWithMembersProvider() {
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'someGroup',
|
'someGroup',
|
||||||
|
@ -539,7 +539,7 @@ class Group_LDAPTest extends TestCase {
|
||||||
case 'ldapDynamicGroupMemberURL':
|
case 'ldapDynamicGroupMemberURL':
|
||||||
return '';
|
return '';
|
||||||
case 'hasPrimaryGroups':
|
case 'hasPrimaryGroups':
|
||||||
case 'ldapNestedGroups';
|
case 'ldapNestedGroups':
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -585,7 +585,7 @@ class Group_LDAPTest extends TestCase {
|
||||||
case 'ldapDynamicGroupMemberURL':
|
case 'ldapDynamicGroupMemberURL':
|
||||||
return '';
|
return '';
|
||||||
case 'hasPrimaryGroups':
|
case 'hasPrimaryGroups':
|
||||||
case 'ldapNestedGroups';
|
case 'ldapNestedGroups':
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -641,7 +641,7 @@ class Group_LDAPTest extends TestCase {
|
||||||
case 'ldapLoginFilter':
|
case 'ldapLoginFilter':
|
||||||
return 'uid=%uid';
|
return 'uid=%uid';
|
||||||
case 'hasPrimaryGroups':
|
case 'hasPrimaryGroups':
|
||||||
case 'ldapNestedGroups';
|
case 'ldapNestedGroups':
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -894,8 +894,8 @@ class Group_LDAPTest extends TestCase {
|
||||||
|
|
||||||
public function nestedGroupsProvider(): array {
|
public function nestedGroupsProvider(): array {
|
||||||
return [
|
return [
|
||||||
[ true ],
|
[true],
|
||||||
[ false ],
|
[false],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue