summaryrefslogtreecommitdiffstats
path: root/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php
diff options
context:
space:
mode:
authorJakub Zalas <jakub@zalas.pl>2014-04-01 15:48:06 +0100
committerJakub Zalas <jakub@zalas.pl>2014-04-01 15:48:06 +0100
commit11c6ba069dbe07aa890760544e38585581a2ee6e (patch)
tree19631b9fcf8a7d0f708d9a3185c56a1d5e147492 /Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php
parentefead6dbd9f02b485753a33c7559797e8a39dc79 (diff)
downloadsymfony-security-11c6ba069dbe07aa890760544e38585581a2ee6e.zip
symfony-security-11c6ba069dbe07aa890760544e38585581a2ee6e.tar.gz
symfony-security-11c6ba069dbe07aa890760544e38585581a2ee6e.tar.bz2
[Security] Replace exception mocks with actual exception instances.v2.3.12
It is done for two reasons: * consistency - we use real exception objects in most of the code * latest phpunit does not like the way we were creating mocks for exceptions (it could be also fixed by letting phpunit to call the original constructor)
Diffstat (limited to 'Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php')
-rw-r--r--Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php b/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php
index 22a7e5d..32f5b10 100644
--- a/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php
+++ b/Tests/Core/Authentication/Provider/UserAuthenticationProviderTest.php
@@ -11,10 +11,12 @@
namespace Symfony\Component\Security\Tests\Core\Authentication\Provider;
-use Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider;
+use Symfony\Component\Security\Core\Exception\AccountExpiredException;
+use Symfony\Component\Security\Core\Exception\BadCredentialsException;
+use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
+use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Role\SwitchUserRole;
-use Symfony\Component\Security\Core\Exception\BadCredentialsException;
class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
{
@@ -41,7 +43,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider(false, false);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false)))
+ ->will($this->throwException(new UsernameNotFoundException()))
;
$provider->authenticate($this->getSupportedToken());
@@ -55,7 +57,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider(false, true);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false)))
+ ->will($this->throwException(new UsernameNotFoundException()))
;
$provider->authenticate($this->getSupportedToken());
@@ -83,7 +85,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
$userChecker->expects($this->once())
->method('checkPreAuth')
- ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\CredentialsExpiredException', null, array(), '', false)))
+ ->will($this->throwException(new CredentialsExpiredException()))
;
$provider = $this->getProvider($userChecker);
@@ -103,7 +105,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
$userChecker->expects($this->once())
->method('checkPostAuth')
- ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false)))
+ ->will($this->throwException(new AccountExpiredException()))
;
$provider = $this->getProvider($userChecker);
@@ -128,7 +130,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
;
$provider->expects($this->once())
->method('checkAuthentication')
- ->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\BadCredentialsException', null, array(), '', false)))
+ ->will($this->throwException(new BadCredentialsException()))
;
$provider->authenticate($this->getSupportedToken());