[Pkg-owncloud-commits] [owncloud] 64/104: LDAP: add tests for countUsers
David Prévot
taffit at moszumanska.debian.org
Sat Jan 18 13:33:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 1636c6dbd844d5747d42e6df706ed9935c5851ad
Author: Arthur Schiwon <blizzz at owncloud.com>
Date: Wed Jan 8 12:24:29 2014 +0100
LDAP: add tests for countUsers
---
apps/user_ldap/tests/user_ldap.php | 54 ++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php
index 6b9b8b3..9193a00 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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list