_ldap = new Zend_Ldap(); } /** * @return void */ public function testInvalidOptionResultsInException() { $optionName = 'invalid'; try { $this->_ldap->setOptions(array($optionName => 'irrelevant')); $this->fail('Expected Zend_Ldap_Exception not thrown'); } catch (Zend_Ldap_Exception $e) { $this->assertEquals("Unknown Zend_Ldap option: $optionName", $e->getMessage()); } } public function testException() { $e = new Zend_Ldap_Exception(null, '', 0); $this->assertEquals('no exception message', $e->getMessage()); $this->assertEquals(0, $e->getCode()); $this->assertEquals(0, $e->getErrorCode()); $e = new Zend_Ldap_Exception(null, '', 15); $this->assertEquals('0xf: no exception message', $e->getMessage()); $this->assertEquals(15, $e->getCode()); $this->assertEquals(15, $e->getErrorCode()); } public function testOptionsGetter() { $options = array( 'host' => TESTS_ZEND_LDAP_HOST, 'username' => TESTS_ZEND_LDAP_USERNAME, 'password' => TESTS_ZEND_LDAP_PASSWORD, 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, ); $ldap = new Zend_Ldap($options); $this->assertEquals(array( 'host' => TESTS_ZEND_LDAP_HOST, 'port' => 0, 'useSsl' => false, 'username' => TESTS_ZEND_LDAP_USERNAME, 'password' => TESTS_ZEND_LDAP_PASSWORD, 'bindRequiresDn' => false, 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, 'accountCanonicalForm' => null, 'accountDomainName' => null, 'accountDomainNameShort' => null, 'accountFilterFormat' => null, 'allowEmptyPassword' => false, 'useStartTls' => false, 'optReferrals' => false, 'tryUsernameSplit' => true ), $ldap->getOptions()); } public function testConfigObject() { /** * @see Zend_Config */ require_once 'Zend/Config.php'; $config = new Zend_Config(array( 'host' => TESTS_ZEND_LDAP_HOST, 'username' => TESTS_ZEND_LDAP_USERNAME, 'password' => TESTS_ZEND_LDAP_PASSWORD, 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, )); $ldap = new Zend_Ldap($config); $this->assertEquals(array( 'host' => TESTS_ZEND_LDAP_HOST, 'port' => 0, 'useSsl' => false, 'username' => TESTS_ZEND_LDAP_USERNAME, 'password' => TESTS_ZEND_LDAP_PASSWORD, 'bindRequiresDn' => false, 'baseDn' => TESTS_ZEND_LDAP_BASE_DN, 'accountCanonicalForm' => null, 'accountDomainName' => null, 'accountDomainNameShort' => null, 'accountFilterFormat' => null, 'allowEmptyPassword' => false, 'useStartTls' => false, 'optReferrals' => false, 'tryUsernameSplit' => true ), $ldap->getOptions()); } }