@@ -26,13 +26,13 @@ class AuthenticationProviderManagerTest extends TestCase
26
26
{
27
27
public function testAuthenticateWithoutProviders ()
28
28
{
29
- $ this ->expectException (' InvalidArgumentException ' );
29
+ $ this ->expectException (\ InvalidArgumentException::class );
30
30
new AuthenticationProviderManager ([]);
31
31
}
32
32
33
33
public function testAuthenticateWithProvidersWithIncorrectInterface ()
34
34
{
35
- $ this ->expectException (' InvalidArgumentException ' );
35
+ $ this ->expectException (\ InvalidArgumentException::class );
36
36
(new AuthenticationProviderManager ([
37
37
new \stdClass (),
38
38
]))->authenticate ($ this ->getMockBuilder (TokenInterface::class)->getMock ());
@@ -45,7 +45,7 @@ public function testAuthenticateWhenNoProviderSupportsToken()
45
45
]);
46
46
47
47
try {
48
- $ manager ->authenticate ($ token = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
48
+ $ manager ->authenticate ($ token = $ this ->getMockBuilder (TokenInterface::class )->getMock ());
49
49
$ this ->fail ();
50
50
} catch (ProviderNotFoundException $ e ) {
51
51
$ this ->assertSame ($ token , $ e ->getToken ());
@@ -54,7 +54,7 @@ public function testAuthenticateWhenNoProviderSupportsToken()
54
54
55
55
public function testAuthenticateWhenProviderReturnsAccountStatusException ()
56
56
{
57
- $ secondAuthenticationProvider = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface ' )->getMock ();
57
+ $ secondAuthenticationProvider = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \Authentication \Provider \AuthenticationProviderInterface::class )->getMock ();
58
58
59
59
$ manager = new AuthenticationProviderManager ([
60
60
$ this ->getAuthenticationProvider (true , null , 'Symfony\Component\Security\Core\Exception\AccountStatusException ' ),
@@ -65,7 +65,7 @@ public function testAuthenticateWhenProviderReturnsAccountStatusException()
65
65
$ secondAuthenticationProvider ->expects ($ this ->never ())->method ('supports ' );
66
66
67
67
try {
68
- $ manager ->authenticate ($ token = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
68
+ $ manager ->authenticate ($ token = $ this ->getMockBuilder (TokenInterface::class )->getMock ());
69
69
$ this ->fail ();
70
70
} catch (AccountStatusException $ e ) {
71
71
$ this ->assertSame ($ token , $ e ->getToken ());
@@ -79,7 +79,7 @@ public function testAuthenticateWhenProviderReturnsAuthenticationException()
79
79
]);
80
80
81
81
try {
82
- $ manager ->authenticate ($ token = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
82
+ $ manager ->authenticate ($ token = $ this ->getMockBuilder (TokenInterface::class )->getMock ());
83
83
$ this ->fail ();
84
84
} catch (AuthenticationException $ e ) {
85
85
$ this ->assertSame ($ token , $ e ->getToken ());
@@ -90,26 +90,26 @@ public function testAuthenticateWhenOneReturnsAuthenticationExceptionButNotAll()
90
90
{
91
91
$ manager = new AuthenticationProviderManager ([
92
92
$ this ->getAuthenticationProvider (true , null , 'Symfony\Component\Security\Core\Exception\AuthenticationException ' ),
93
- $ this ->getAuthenticationProvider (true , $ expected = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ()),
93
+ $ this ->getAuthenticationProvider (true , $ expected = $ this ->getMockBuilder (TokenInterface::class )->getMock ()),
94
94
]);
95
95
96
- $ token = $ manager ->authenticate ($ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
96
+ $ token = $ manager ->authenticate ($ this ->getMockBuilder (TokenInterface::class )->getMock ());
97
97
$ this ->assertSame ($ expected , $ token );
98
98
}
99
99
100
100
public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider ()
101
101
{
102
- $ second = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface ' )->getMock ();
102
+ $ second = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \Authentication \Provider \AuthenticationProviderInterface::class )->getMock ();
103
103
$ second
104
104
->expects ($ this ->never ())
105
105
->method ('supports ' )
106
106
;
107
107
$ manager = new AuthenticationProviderManager ([
108
- $ this ->getAuthenticationProvider (true , $ expected = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ()),
108
+ $ this ->getAuthenticationProvider (true , $ expected = $ this ->getMockBuilder (TokenInterface::class )->getMock ()),
109
109
$ second ,
110
110
]);
111
111
112
- $ token = $ manager ->authenticate ($ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
112
+ $ token = $ manager ->authenticate ($ this ->getMockBuilder (TokenInterface::class )->getMock ());
113
113
$ this ->assertSame ($ expected , $ token );
114
114
}
115
115
@@ -119,25 +119,25 @@ public function testEraseCredentialFlag()
119
119
$ this ->getAuthenticationProvider (true , $ token = new UsernamePasswordToken ('foo ' , 'bar ' , 'key ' )),
120
120
]);
121
121
122
- $ token = $ manager ->authenticate ($ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
122
+ $ token = $ manager ->authenticate ($ this ->getMockBuilder (TokenInterface::class )->getMock ());
123
123
$ this ->assertEquals ('' , $ token ->getCredentials ());
124
124
125
125
$ manager = new AuthenticationProviderManager ([
126
126
$ this ->getAuthenticationProvider (true , $ token = new UsernamePasswordToken ('foo ' , 'bar ' , 'key ' )),
127
127
], false );
128
128
129
- $ token = $ manager ->authenticate ($ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Token\ TokenInterface' )->getMock ());
129
+ $ token = $ manager ->authenticate ($ this ->getMockBuilder (TokenInterface::class )->getMock ());
130
130
$ this ->assertEquals ('bar ' , $ token ->getCredentials ());
131
131
}
132
132
133
133
public function testAuthenticateDispatchesAuthenticationFailureEvent ()
134
134
{
135
135
$ token = new UsernamePasswordToken ('foo ' , 'bar ' , 'key ' );
136
- $ provider = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface ' )->getMock ();
136
+ $ provider = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \Authentication \Provider \AuthenticationProviderInterface::class )->getMock ();
137
137
$ provider ->expects ($ this ->once ())->method ('supports ' )->willReturn (true );
138
138
$ provider ->expects ($ this ->once ())->method ('authenticate ' )->willThrowException ($ exception = new AuthenticationException ());
139
139
140
- $ dispatcher = $ this ->getMockBuilder (' Symfony\Component\EventDispatcher\EventDispatcherInterface ' )->getMock ();
140
+ $ dispatcher = $ this ->getMockBuilder (\ Symfony \Component \EventDispatcher \EventDispatcherInterface::class )->getMock ();
141
141
$ dispatcher
142
142
->expects ($ this ->once ())
143
143
->method ('dispatch ' )
@@ -158,11 +158,11 @@ public function testAuthenticateDispatchesAuthenticationSuccessEvent()
158
158
{
159
159
$ token = new UsernamePasswordToken ('foo ' , 'bar ' , 'key ' );
160
160
161
- $ provider = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface ' )->getMock ();
161
+ $ provider = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \Authentication \Provider \AuthenticationProviderInterface::class )->getMock ();
162
162
$ provider ->expects ($ this ->once ())->method ('supports ' )->willReturn (true );
163
163
$ provider ->expects ($ this ->once ())->method ('authenticate ' )->willReturn ($ token );
164
164
165
- $ dispatcher = $ this ->getMockBuilder (' Symfony\Component\EventDispatcher\EventDispatcherInterface ' )->getMock ();
165
+ $ dispatcher = $ this ->getMockBuilder (\ Symfony \Component \EventDispatcher \EventDispatcherInterface::class )->getMock ();
166
166
$ dispatcher
167
167
->expects ($ this ->once ())
168
168
->method ('dispatch ' )
@@ -176,7 +176,7 @@ public function testAuthenticateDispatchesAuthenticationSuccessEvent()
176
176
177
177
protected function getAuthenticationProvider ($ supports , $ token = null , $ exception = null )
178
178
{
179
- $ provider = $ this ->getMockBuilder (' Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface ' )->getMock ();
179
+ $ provider = $ this ->getMockBuilder (\ Symfony \Component \Security \Core \Authentication \Provider \AuthenticationProviderInterface::class )->getMock ();
180
180
$ provider ->expects ($ this ->once ())
181
181
->method ('supports ' )
182
182
->willReturn ($ supports )
0 commit comments