private function getPluginManagerMock() {
return $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')->getMock();
}
-
+
/**
* @param Access|\PHPUnit_Framework_MockObject_MockObject $access
*/
}
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')
->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')
$ldap = new GroupLDAP($access, $pluginManager);
$this->assertEquals($ldap->countUsersInGroup('gid', 'search'),42);
- }
+ }
public function testGidNumber2NameSuccess() {
$access = $this->getAccessMock();
$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')
$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']);
$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')
$this->assertEquals($ldap->createGroup('gid'),true);
}
-
+
public function testCreateGroupFailing() {
$this->expectException(\Exception::class);
$this->assertEquals($ldap->deleteGroup('gid'),'result');
}
-
+
public function testDeleteGroupFailing() {
$this->expectException(\Exception::class);
$this->assertEquals($ldap->addToGroup('uid', 'gid'),'result');
}
-
+
public function testAddToGroupFailing() {
$this->expectException(\Exception::class);
$this->assertEquals($ldap->removeFromGroup('uid', 'gid'),'result');
}
-
+
public function testRemoveFromGroupFailing() {
$this->expectException(\Exception::class);
$this->assertEquals($ldap->getGroupDetails('gid'),'result');
}
-
+
public function testGetGroupDetailsFailing() {
$this->expectException(\Exception::class);