function it_should_call_the_event_dispatchers($connection, $dispatcher)
{
$operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar');
$connection->connect('foo', 'bar', false, null)->willReturn($connection);
$connection->isBound()->willReturn(true);
$connection->close()->willReturn($connection);
$connection->connect()->willReturn($connection);
$dispatcher->dispatch(new LdapAuthenticationEvent(Event::LDAP_AUTHENTICATION_BEFORE, $operation))->shouldBeCalled();
$dispatcher->dispatch(new LdapAuthenticationEvent(Event::LDAP_AUTHENTICATION_AFTER, $operation, new AuthenticationResponse(true)))->shouldBeCalled();
$this->execute($operation)->shouldReturnAnInstanceOf('\\LdapTools\\Operation\\AuthenticationResponse');
}