public function testGetErrorCode() { $ldap = new Ldap\Ldap($this->_options); try { // Connect doesn't actually try to connect until bind is called // but if we get 'Invalid credentials' then we know the connect // succeeded. $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); $this->fail('Expected exception for invalid username'); } catch (Ldap\Exception $zle) { $this->assertContains('Invalid credentials', $zle->getMessage()); $this->assertEquals(0x31, $zle->getCode()); $this->assertEquals(0x0, Ldap\Exception::getLDAPCode($ldap)); $this->assertEquals(0x0, Ldap\Exception::getLDAPCode(null)); } }