eZ\Publish\Core\MVC\Symfony\Security\Tests\UserWrappedTest::testRegularUser PHP Method

testRegularUser() public method

public testRegularUser ( )
    public function testRegularUser()
    {
        $originalUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
        $user = new UserWrapped($originalUser, $this->apiUser);
        $this->assertTrue($user->isEnabled());
        $this->assertTrue($user->isAccountNonExpired());
        $this->assertTrue($user->isAccountNonLocked());
        $this->assertTrue($user->isCredentialsNonExpired());
        $this->assertTrue($user->isEqualTo($this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface')));
        $originalUser->expects($this->once())->method('eraseCredentials');
        $user->eraseCredentials();
        $username = 'lolautruche';
        $password = 'NoThisIsNotMyRealPassword';
        $roles = array('ROLE_USER', 'ROLE_TEST');
        $salt = md5(microtime(true));
        $originalUser->expects($this->exactly(2))->method('getUsername')->will($this->returnValue($username));
        $originalUser->expects($this->once())->method('getPassword')->will($this->returnValue($password));
        $originalUser->expects($this->once())->method('getRoles')->will($this->returnValue($roles));
        $originalUser->expects($this->once())->method('getSalt')->will($this->returnValue($salt));
        $this->assertSame($username, $user->getUsername());
        $this->assertSame($username, (string) $user);
        $this->assertSame($password, $user->getPassword());
        $this->assertSame($roles, $user->getRoles());
        $this->assertSame($salt, $user->getSalt());
        $this->assertSame($originalUser, $user->getWrappedUser());
    }