function it_should_not_authenticate_if_a_bind_exception_is_thrown($connection)
{
$ex = new LdapBindException('Foo');
$operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar');
$connection->connect('foo', 'bar', false, null)->willThrow($ex);
$connection->getLastError()->willReturn('foo');
$connection->getExtendedErrorNumber()->willReturn(99);
$connection->isBound()->willReturn(true);
$connection->close()->willReturn($connection);
$connection->connect()->willReturn($connection);
$this->execute($operation)->shouldReturnAnInstanceOf('\\LdapTools\\Operation\\AuthenticationResponse');
$this->execute($operation)->isAuthenticated()->shouldBeEqualTo(false);
$this->execute($operation)->getErrorMessage()->shouldBeEqualTo('foo');
$this->execute($operation)->getErrorCode()->shouldBeEqualTo(99);
}