summaryrefslogtreecommitdiffstats
path: root/Core
diff options
context:
space:
mode:
authorTobias Sjösten <tobias@tobiassjosten.net>2013-12-15 10:16:22 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2015-02-05 16:54:07 +0100
commit7efc95077540fd649e1dbd98fb498461be1254ca (patch)
tree883057c96551a7078728560ac6e78505e0dee672 /Core
parenta83c8a68db8510d9d5f0a62bcb56e45625bc19d7 (diff)
downloadsymfony-security-7efc95077540fd649e1dbd98fb498461be1254ca.zip
symfony-security-7efc95077540fd649e1dbd98fb498461be1254ca.tar.gz
symfony-security-7efc95077540fd649e1dbd98fb498461be1254ca.tar.bz2
[Security] added string representation for core Users
Diffstat (limited to 'Core')
-rw-r--r--Core/Tests/User/UserTest.php9
-rw-r--r--Core/User/User.php5
2 files changed, 14 insertions, 0 deletions
diff --git a/Core/Tests/User/UserTest.php b/Core/Tests/User/UserTest.php
index 2fe6daa..f514eda 100644
--- a/Core/Tests/User/UserTest.php
+++ b/Core/Tests/User/UserTest.php
@@ -123,4 +123,13 @@ class UserTest extends \PHPUnit_Framework_TestCase
$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);
+ }
}
diff --git a/Core/User/User.php b/Core/User/User.php
index ea2c6a4..d458b72 100644
--- a/Core/User/User.php
+++ b/Core/User/User.php
@@ -43,6 +43,11 @@ final class User implements AdvancedUserInterface
$this->roles = $roles;
}
+ public function __toString()
+ {
+ return $this->getUsername();
+ }
+
/**
* {@inheritdoc}
*/