getUsername() public method

Returns the username used to authenticate the user.
public getUsername ( ) : string
return string The username
示例#1
0
 public function testConstruct()
 {
     $login = '******';
     $passwordHash = 'encoded_password';
     $apiUser = $this->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\User\\User')->setConstructorArgs(array(array('login' => $login, 'passwordHash' => $passwordHash, 'enabled' => true)))->getMockForAbstractClass();
     $roles = array('ROLE_USER');
     $user = new User($apiUser, $roles);
     $this->assertSame($apiUser, $user->getAPIUser());
     $this->assertSame($login, $user->getUsername());
     $this->assertSame($passwordHash, $user->getPassword());
     $this->assertSame($roles, $user->getRoles());
     $this->assertNull($user->getSalt());
     $this->assertTrue($user->isAccountNonExpired());
     $this->assertTrue($user->isAccountNonLocked());
     $this->assertTrue($user->isCredentialsNonExpired());
     $this->assertTrue($user->isEnabled());
 }