From 3e1b1e02494f7bc4512a355cc6a198b7786f8cfe Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 5 Feb 2017 19:34:12 -0500 Subject: Improve LDAP error reporting --- tests/units/Core/Ldap/ClientTest.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'tests/units/Core/Ldap/ClientTest.php') diff --git a/tests/units/Core/Ldap/ClientTest.php b/tests/units/Core/Ldap/ClientTest.php index d149500e..9f007c28 100644 --- a/tests/units/Core/Ldap/ClientTest.php +++ b/tests/units/Core/Ldap/ClientTest.php @@ -13,6 +13,21 @@ function ldap_set_option() { } +function ldap_get_option($link_identifier, $option, &$error) +{ + $error = 'some extended error'; +} + +function ldap_error($link_identifier) +{ + return 'some error'; +} + +function ldap_errno($link_identifier) +{ + return -100; +} + function ldap_bind($link_identifier, $bind_rdn = null, $bind_password = null) { return ClientTest::$functions->ldap_bind($link_identifier, $bind_rdn, $bind_password); @@ -26,7 +41,6 @@ function ldap_start_tls($link_identifier) class ClientTest extends \Base { public static $functions; - private $ldap; public function setUp() { @@ -37,8 +51,11 @@ class ClientTest extends \Base ->setMethods(array( 'ldap_connect', 'ldap_set_option', + 'ldap_get_option', 'ldap_bind', 'ldap_start_tls', + 'ldap_error', + 'ldap_errno' )) ->getMock(); } @@ -83,7 +100,7 @@ class ClientTest extends \Base ) ->will($this->returnValue(false)); - $this->setExpectedException('\Kanboard\Core\Ldap\ClientException'); + $this->setExpectedException('\Kanboard\Core\Ldap\ConnectionException'); $ldap = new Client; $ldap->open('my_ldap_server'); @@ -133,7 +150,7 @@ class ClientTest extends \Base ) ->will($this->returnValue(false)); - $this->setExpectedException('\Kanboard\Core\Ldap\ClientException'); + $this->setExpectedException('\Kanboard\Core\Ldap\ConnectionException'); $ldap = new Client; $ldap->open('my_ldap_server', 389, true); -- cgit v1.2.3