Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 97750f7

Browse files
committed
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
2 parents 5925780 + 3dfaa19 commit 97750f7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/Symfony/Component/Security/Core/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)