public function testException() { $e = new LDAP\Exception(null, '', 0); $this->assertEquals('no exception message', $e->getMessage()); $this->assertEquals(0, $e->getCode()); $this->assertEquals(0, $e->getErrorCode()); $e = new LDAP\Exception(null, '', 15); $this->assertEquals('0xf: no exception message', $e->getMessage()); $this->assertEquals(15, $e->getCode()); $this->assertEquals(15, $e->getErrorCode()); }
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)); } }