11
11
12
12
namespace Symfony \Component \Security \Tests \Core \Authentication \Provider ;
13
13
14
- use Symfony \Component \Security \Core \Authentication \Provider \UserAuthenticationProvider ;
14
+ use Symfony \Component \Security \Core \Exception \AccountExpiredException ;
15
+ use Symfony \Component \Security \Core \Exception \BadCredentialsException ;
16
+ use Symfony \Component \Security \Core \Exception \CredentialsExpiredException ;
17
+ use Symfony \Component \Security \Core \Exception \UsernameNotFoundException ;
15
18
use Symfony \Component \Security \Core \Role \Role ;
16
19
use Symfony \Component \Security \Core \Role \SwitchUserRole ;
17
- use Symfony \Component \Security \Core \Exception \BadCredentialsException ;
18
20
19
21
class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
20
22
{
@@ -41,7 +43,7 @@ public function testAuthenticateWhenUsernameIsNotFound()
41
43
$ provider = $ this ->getProvider (false , false );
42
44
$ provider ->expects ($ this ->once ())
43
45
->method ('retrieveUser ' )
44
- ->will ($ this ->throwException ($ this -> getMock ( ' Symfony\Component\Security\Core\Exception\UsernameNotFoundException ' , null , array (), '' , false )))
46
+ ->will ($ this ->throwException (new UsernameNotFoundException ( )))
45
47
;
46
48
47
49
$ provider ->authenticate ($ this ->getSupportedToken ());
@@ -55,7 +57,7 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
55
57
$ provider = $ this ->getProvider (false , true );
56
58
$ provider ->expects ($ this ->once ())
57
59
->method ('retrieveUser ' )
58
- ->will ($ this ->throwException ($ this -> getMock ( ' Symfony\Component\Security\Core\Exception\UsernameNotFoundException ' , null , array (), '' , false )))
60
+ ->will ($ this ->throwException (new UsernameNotFoundException ( )))
59
61
;
60
62
61
63
$ provider ->authenticate ($ this ->getSupportedToken ());
@@ -83,7 +85,7 @@ public function testAuthenticateWhenPreChecksFails()
83
85
$ userChecker = $ this ->getMock ('Symfony\Component\Security\Core\User\UserCheckerInterface ' );
84
86
$ userChecker ->expects ($ this ->once ())
85
87
->method ('checkPreAuth ' )
86
- ->will ($ this ->throwException ($ this -> getMock ( ' Symfony\Component\Security\Core\Exception\CredentialsExpiredException ' , null , array (), '' , false )))
88
+ ->will ($ this ->throwException (new CredentialsExpiredException ( )))
87
89
;
88
90
89
91
$ provider = $ this ->getProvider ($ userChecker );
@@ -103,7 +105,7 @@ public function testAuthenticateWhenPostChecksFails()
103
105
$ userChecker = $ this ->getMock ('Symfony\Component\Security\Core\User\UserCheckerInterface ' );
104
106
$ userChecker ->expects ($ this ->once ())
105
107
->method ('checkPostAuth ' )
106
- ->will ($ this ->throwException ($ this -> getMock ( ' Symfony\Component\Security\Core\Exception\AccountExpiredException ' , null , array (), '' , false )))
108
+ ->will ($ this ->throwException (new AccountExpiredException ( )))
107
109
;
108
110
109
111
$ provider = $ this ->getProvider ($ userChecker );
@@ -128,7 +130,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails()
128
130
;
129
131
$ provider ->expects ($ this ->once ())
130
132
->method ('checkAuthentication ' )
131
- ->will ($ this ->throwException ($ this -> getMock ( ' Symfony\Component\Security\Core\Exception\BadCredentialsException ' , null , array (), '' , false )))
133
+ ->will ($ this ->throwException (new BadCredentialsException ( )))
132
134
;
133
135
134
136
$ provider ->authenticate ($ this ->getSupportedToken ());
0 commit comments