Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
adapt tests for nc18
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Aug 12, 2020
commit 268fff8c58b2a448955ede4980c309043e5ec368
38 changes: 28 additions & 10 deletions apps/user_ldap/tests/Group_LDAPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function getAccessMock() {
private function getPluginManagerMock() {
return $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')->getMock();
}

/**
* @param Access|\PHPUnit_Framework_MockObject_MockObject $access
*/
Expand Down Expand Up @@ -121,7 +121,12 @@ public function testCountEmptySearchString() {
}
return [];
});

$access->expects($this->any())
->method('combineFilterWithAnd')
->willReturn('pseudo=filter');
$access->expects($this->any())
->method('fetchListOfUsers')
->will($this->returnValue([])); // return val does not matter here
// for primary groups
$access->expects($this->once())
->method('countUsers')
Expand Down Expand Up @@ -170,6 +175,9 @@ public function testCountWithSearchString() {
->will($this->returnCallback(function() {
return 'foobar' . \OC::$server->getSecureRandom()->generate(7);
}));
$access->expects($this->any())
->method('combineFilterWithAnd')
->willReturn('pseudo=filter');

$access->userManager->expects($this->any())
->method('getAttributes')
Expand Down Expand Up @@ -203,7 +211,7 @@ public function testCountUsersWithPlugin() {
$ldap = new GroupLDAP($access, $pluginManager);

$this->assertEquals($ldap->countUsersInGroup('gid', 'search'),42);
}
}

public function testGidNumber2NameSuccess() {
$access = $this->getAccessMock();
Expand Down Expand Up @@ -543,6 +551,9 @@ public function testUsersInGroupPrimaryMembersOnly() {
$access->expects($this->exactly(2))
->method('nextcloudUserNames')
->willReturnOnConsecutiveCalls(['lisa', 'bart', 'kira', 'brad'], ['walle', 'dino', 'xenia']);
$access->expects($this->any())
->method('fetchListOfUsers')
->will($this->returnValue([])); // return val does not matter here

$access->userManager->expects($this->any())
->method('getAttributes')
Expand Down Expand Up @@ -581,7 +592,9 @@ public function testUsersInGroupPrimaryAndUnixMembers() {
$access->expects($this->once())
->method('nextcloudUserNames')
->will($this->returnValue(array('lisa', 'bart', 'kira', 'brad')));

$access->expects($this->any())
->method('fetchListOfUsers')
->will($this->returnValue([])); // return val does not matter here
$access->userManager->expects($this->any())
->method('getAttributes')
->willReturn(['displayName', 'mail']);
Expand Down Expand Up @@ -618,10 +631,15 @@ public function testCountUsersInGroupPrimaryMembersOnly() {
$access->expects($this->any())
->method('groupname2dn')
->will($this->returnValue('cn=foobar,dc=foo,dc=bar'));

$access->expects($this->any())
->method('fetchListOfUsers')
->will($this->returnValue([])); // return val does not matter here
$access->expects($this->once())
->method('countUsers')
->will($this->returnValue(4));
$access->expects($this->any())
->method('combineFilterWithAnd')
->willReturn('pseudo=filter');

$access->userManager->expects($this->any())
->method('getAttributes')
Expand Down Expand Up @@ -790,7 +808,7 @@ public function testCreateGroupWithPlugin() {
$this->assertEquals($ldap->createGroup('gid'),true);
}


public function testCreateGroupFailing() {
$this->expectException(\Exception::class);

Expand Down Expand Up @@ -845,7 +863,7 @@ public function testDeleteGroupWithPlugin() {
$this->assertEquals($ldap->deleteGroup('gid'),'result');
}


public function testDeleteGroupFailing() {
$this->expectException(\Exception::class);

Expand Down Expand Up @@ -891,7 +909,7 @@ public function testAddToGroupWithPlugin() {
$this->assertEquals($ldap->addToGroup('uid', 'gid'),'result');
}


public function testAddToGroupFailing() {
$this->expectException(\Exception::class);

Expand Down Expand Up @@ -937,7 +955,7 @@ public function testRemoveFromGroupWithPlugin() {
$this->assertEquals($ldap->removeFromGroup('uid', 'gid'),'result');
}


public function testRemoveFromGroupFailing() {
$this->expectException(\Exception::class);

Expand Down Expand Up @@ -983,7 +1001,7 @@ public function testGetGroupDetailsWithPlugin() {
$this->assertEquals($ldap->getGroupDetails('gid'),'result');
}


public function testGetGroupDetailsFailing() {
$this->expectException(\Exception::class);

Expand Down