feature #10427 Username in UsernameNotFoundException message data (maryo)

This PR was squashed before being merged into the 2.6-dev branch (closes #10427).

Discussion
----------

Username in UsernameNotFoundException message data

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Added username in UsernameNotFoundException message data

Commits
-------

3dfaa19 Username in UsernameNotFoundException message data
This commit is contained in:
Fabien Potencier 2014-06-06 05:53:34 +02:00
commit 97750f7b02
2 changed files with 33 additions and 0 deletions

View File

@ -69,4 +69,12 @@ class UsernameNotFoundException extends AuthenticationException
parent::unserialize($parentData);
}
/**
* {@inheritDoc}
*/
public function getMessageData()
{
return array('{{ username }}' => $this->username);
}
}

View File

@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Tests\Core\Exception;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
class UsernameNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testGetMessageData()
{
$exception = new UsernameNotFoundException('Username could not be found.');
$this->assertEquals(array('{{ username }}' => null), $exception->getMessageData());
$exception->setUsername('username');
$this->assertEquals(array('{{ username }}' => 'username'), $exception->getMessageData());
}
}