/**
* @param \Symfony\Component\Security\Core\User\UserProviderInterface $userProvider
* @param \LdapTools\Bundle\LdapToolsBundle\Security\User\LdapUserChecker $userChecker
* @param \LdapTools\LdapManager $ldap
* @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token
* @param \LdapTools\Bundle\LdapToolsBundle\Security\User\LdapUser $user
* @param \LdapTools\Connection\LdapConnectionInterface $connection
* @param \LdapTools\Operation\AuthenticationResponse $response
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
*/
function let($userProvider, $userChecker, $ldap, $token, $user, $connection, $response, $dispatcher)
{
$this->userProvider = $userProvider;
$this->userChecker = $userChecker;
$this->ldap = $ldap;
$this->token = $token;
$this->user = $user;
$this->connection = $connection;
$this->operation = (new AuthenticationOperation())->setUsername('foo')->setPassword('bar');
$this->response = $response;
$this->dispatcher = $dispatcher;
$token->getUsername()->willReturn('foo');
$token->getCredentials()->willReturn('bar');
$token->hasAttribute('ldap_domain')->willReturn(false);
$token->getAttributes()->willReturn([]);
$this->userProvider->loadUserByUsername('foo')->willReturn($user);
$this->connection->getConfig()->willReturn(new DomainConfiguration('foo.bar'));
$this->connection->execute($this->operation)->willReturn($this->response);
$this->response->isAuthenticated()->willReturn(true);
$this->ldap->getConnection()->willReturn($this->connection);
$this->ldap->getDomainContext()->willReturn('foo.bar');
$this->user->getUsername()->willReturn('foo');
$this->user->getRoles()->willReturn(['ROLE_USER']);
$this->user->isAccountNonLocked()->willReturn(true);
$this->user->isEnabled()->willReturn(true);
$this->user->isAccountNonExpired()->willReturn(true);
$this->user->isCredentialsNonExpired()->willReturn(true);
$this->beConstructedWith('restricted', true, $this->userProvider, new LdapUserChecker(), $this->ldap, $this->dispatcher);
}