Skip to content

Commit a276fc8

Browse files
maryofabpot
authored andcommitted
Username in UsernameNotFoundException message data
1 parent a5f7ad6 commit a276fc8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Exception/UsernameNotFoundException.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,12 @@ public function unserialize($str)
6969

7070
parent::unserialize($parentData);
7171
}
72+
73+
/**
74+
* {@inheritDoc}
75+
*/
76+
public function getMessageData()
77+
{
78+
return array('{{ username }}' => $this->username);
79+
}
7280
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Tests\Core\Exception;
13+
14+
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
15+
16+
class UsernameNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
17+
{
18+
public function testGetMessageData()
19+
{
20+
$exception = new UsernameNotFoundException('Username could not be found.');
21+
$this->assertEquals(array('{{ username }}' => null), $exception->getMessageData());
22+
$exception->setUsername('username');
23+
$this->assertEquals(array('{{ username }}' => 'username'), $exception->getMessageData());
24+
}
25+
}

0 commit comments

Comments
 (0)