Username in UsernameNotFoundException message data

This commit is contained in:
Marek Štípek 2014-03-12 11:37:08 +01:00 committed by Fabien Potencier
parent c2d4be1d6b
commit 3dfaa19518
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());
}
}