function it_should_authenticate_a_user_and_stay_connected_as_them_if_specified(DomainConfiguration $config, $connection)
{
$operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar')->setSwitchToCredentials(true);
$connection->connect('foo', 'bar', false, null)->willReturn($connection);
$connection->isBound()->willReturn(true);
$connection->close()->willReturn($connection);
$connection->getConfig()->willReturn($config);
// The credentials are switched in the config itself...
$config->setUsername('foo')->shouldBeCalled();
$config->setPassword('bar')->shouldBeCalled();
$this->execute($operation)->shouldReturnAnInstanceOf('\\LdapTools\\Operation\\AuthenticationResponse');
}