Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Security] added string representation for core Users
  • Loading branch information
tobiassjosten authored and fabpot committed Feb 5, 2015
1 parent 1882cb1 commit 722c3a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Symfony/Component/Security/Core/Tests/User/UserTest.php
Expand Up @@ -123,4 +123,13 @@ public function testEraseCredentials()
$user->eraseCredentials();
$this->assertEquals('superpass', $user->getPassword());
}

/**
* @covers Symfony\Component\Security\Core\User\User::__toString
*/
public function testToString()
{
$user = new User('fabien', 'superpass');
$this->assertEquals('fabien', (string) $user);
}
}
5 changes: 5 additions & 0 deletions src/Symfony/Component/Security/Core/User/User.php
Expand Up @@ -43,6 +43,11 @@ public function __construct($username, $password, array $roles = array(), $enabl
$this->roles = $roles;
}

public function __toString()
{
return $this->getUsername();
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 722c3a7

Please sign in to comment.