From 24c224ddc224f68521f3143d66754742311d2a83 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 17 Mar 2016 22:24:11 -0400 Subject: Added support for multiple placeholders for LDAP_USER_FILTER --- tests/units/Core/Ldap/LdapUserTest.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'tests/units/Core') diff --git a/tests/units/Core/Ldap/LdapUserTest.php b/tests/units/Core/Ldap/LdapUserTest.php index 2b3db1e5..b4b63053 100644 --- a/tests/units/Core/Ldap/LdapUserTest.php +++ b/tests/units/Core/Ldap/LdapUserTest.php @@ -321,8 +321,6 @@ class LdapUserTest extends Base public function testGetUserNotFound() { - $entries = new Entries(array()); - $this->client ->expects($this->any()) ->method('getConnection') @@ -376,4 +374,30 @@ class LdapUserTest extends Base $user = new User($this->query); $user->getBasDn(); } + + public function testGetLdapUserPatternNotConfigured() + { + $this->setExpectedException('\LogicException'); + + $user = new User($this->query); + $user->getLdapUserPattern('test'); + } + + public function testGetLdapUserWithMultiplePlaceholders() + { + $filter = '(|(&(objectClass=user)(mail=%s))(&(objectClass=user)(sAMAccountName=%s)))'; + $expected = '(|(&(objectClass=user)(mail=test))(&(objectClass=user)(sAMAccountName=test)))'; + + $user = new User($this->query); + $this->assertEquals($expected, $user->getLdapUserPattern('test', $filter)); + } + + public function testGetLdapUserWithOnePlaceholder() + { + $filter = '(sAMAccountName=%s)'; + $expected = '(sAMAccountName=test)'; + + $user = new User($this->query); + $this->assertEquals($expected, $user->getLdapUserPattern('test', $filter)); + } } -- cgit v1.2.3