public function testCheckAuthentication()
{
$user = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Security\\User');
$userName = 'my_username';
$password = 'foo';
$token = new UsernamePasswordToken($userName, $password, 'bar');
$apiUser = $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\User\\User');
$userService = $this->getMock('eZ\\Publish\\API\\Repository\\UserService');
$userService->expects($this->once())->method('loadUserByCredentials')->with($userName, $password)->will($this->returnValue($apiUser));
$this->repository->expects($this->once())->method('getUserService')->will($this->returnValue($userService));
$this->repository->expects($this->once())->method('setCurrentUser')->with($apiUser);
$method = new \ReflectionMethod($this->authProvider, 'checkAuthentication');
$method->setAccessible(true);
$method->invoke($this->authProvider, $user, $token);
}