$user can be either the user ID or an instance of \eZ\Publish\Core\MVC\Symfony\Security\User
(anonymous user we try to check access via SecurityContext::isGranted()).
public loadUserByUsername ( string | |
||
$user | string | |
Either the user ID to load an instance of User object. A value of -1 represents an anonymous user. |
Résultat | eZ\Publish\Core\MVC\Symfony\Security\UserInterface |
public function testLoadUserByUsername() { $username = '******'; $apiUser = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\User'); $this->userService->expects($this->once())->method('loadUserByLogin')->with($username)->will($this->returnValue($apiUser)); $user = $this->userProvider->loadUserByUsername($username); $this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Symfony\\Security\\UserInterface', $user); $this->assertSame($apiUser, $user->getAPIUser()); $this->assertSame(array('ROLE_USER'), $user->getRoles()); }