summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-01-08 12:24:29 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-01-08 12:24:29 +0100
commit677d83d45fed6e799b9d90927f365d47ba08f93b (patch)
tree1ca801d81894124fa0fffad0b50259988abc9dd8 /apps
parent53498bc8761d564ee44f1d59e8b85873b5d654da (diff)
downloadnextcloud-server-677d83d45fed6e799b9d90927f365d47ba08f93b.tar.gz
nextcloud-server-677d83d45fed6e799b9d90927f365d47ba08f93b.zip
LDAP: add tests for countUsers
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/tests/user_ldap.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php
index 6b9b8b3e185..9193a005ae5 100644
--- a/apps/user_ldap/tests/user_ldap.php
+++ b/apps/user_ldap/tests/user_ldap.php
@@ -408,4 +408,58 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
//no test for getDisplayNames, because it just invokes getUsers and
//getDisplayName
+
+ public function testCountUsers() {
+ $access = $this->getAccessMock();
+
+ $access->connection->expects($this->once())
+ ->method('__get')
+ ->will($this->returnCallback(function($name) {
+ if($name === 'ldapLoginFilter') {
+ return 'uid=%uid';
+ }
+ return null;
+ }));
+
+ $access->expects($this->once())
+ ->method('countUsers')
+ ->will($this->returnCallback(function($filter, $a, $b, $c) {
+ if($filter !== 'uid=*') {
+ return false;
+ }
+ return 5;
+ }));
+
+ $backend = new UserLDAP($access);
+
+ $result = $backend->countUsers();
+ $this->assertEquals(5, $result);
+ }
+
+ public function testCountUsersFailing() {
+ $access = $this->getAccessMock();
+
+ $access->connection->expects($this->once())
+ ->method('__get')
+ ->will($this->returnCallback(function($name) {
+ if($name === 'ldapLoginFilter') {
+ return 'invalidFilter';
+ }
+ return null;
+ }));
+
+ $access->expects($this->once())
+ ->method('countUsers')
+ ->will($this->returnCallback(function($filter, $a, $b, $c) {
+ if($filter !== 'uid=*') {
+ return false;
+ }
+ return 5;
+ }));
+
+ $backend = new UserLDAP($access);
+
+ $result = $backend->countUsers();
+ $this->assertFalse($result);
+ }
} \ No newline at end of file