function it_should_not_switch_credentials_on_an_authentication_failure($connection)
{
$ex = new LdapBindException('Foo');
$operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar')->setSwitchToCredentials(true);
$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 is a sufficient check, as it must get the config to change the user/pass.
$connection->getConfig()->shouldNotBeCalled();
$this->execute($operation)->shouldReturnAnInstanceOf('\\LdapTools\\Operation\\AuthenticationResponse');
}