18
18
use Symfony \Component \Security \Core \Authentication \AuthenticationManagerInterface ;
19
19
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorage ;
20
20
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
21
+ use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
21
22
use Symfony \Component \Security \Core \Authorization \AccessDecisionManagerInterface ;
23
+ use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
24
+ use Symfony \Component \Security \Core \Exception \AuthenticationCredentialsNotFoundException ;
22
25
use Symfony \Component \Security \Http \AccessMapInterface ;
23
26
use Symfony \Component \Security \Http \Event \LazyResponseEvent ;
24
27
use Symfony \Component \Security \Http \Firewall \AccessListener ;
@@ -27,7 +30,7 @@ class AccessListenerTest extends TestCase
27
30
{
28
31
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess ()
29
32
{
30
- $ this ->expectException (\ Symfony \ Component \ Security \ Core \ Exception \ AccessDeniedException::class);
33
+ $ this ->expectException (AccessDeniedException::class);
31
34
$ request = new Request ();
32
35
33
36
$ accessMap = $ this ->getMockBuilder (AccessMapInterface::class)->getMock ();
@@ -38,7 +41,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
38
41
->willReturn ([['foo ' => 'bar ' ], null ])
39
42
;
40
43
41
- $ token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
44
+ $ token = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
42
45
$ token
43
46
->expects ($ this ->any ())
44
47
->method ('isAuthenticated ' )
@@ -82,14 +85,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
82
85
->willReturn ([['foo ' => 'bar ' ], null ])
83
86
;
84
87
85
- $ notAuthenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
88
+ $ notAuthenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
86
89
$ notAuthenticatedToken
87
90
->expects ($ this ->any ())
88
91
->method ('isAuthenticated ' )
89
92
->willReturn (false )
90
93
;
91
94
92
- $ authenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
95
+ $ authenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
93
96
$ authenticatedToken
94
97
->expects ($ this ->any ())
95
98
->method ('isAuthenticated ' )
@@ -146,7 +149,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
146
149
->willReturn ([null , null ])
147
150
;
148
151
149
- $ token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
152
+ $ token = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
150
153
$ token
151
154
->expects ($ this ->never ())
152
155
->method ('isAuthenticated ' )
@@ -201,7 +204,7 @@ public function testHandleWhenAccessMapReturnsEmptyAttributes()
201
204
202
205
public function testHandleWhenTheSecurityTokenStorageHasNoToken ()
203
206
{
204
- $ this ->expectException (\ Symfony \ Component \ Security \ Core \ Exception \ AuthenticationCredentialsNotFoundException::class);
207
+ $ this ->expectException (AuthenticationCredentialsNotFoundException::class);
205
208
$ tokenStorage = $ this ->getMockBuilder (TokenStorageInterface::class)->getMock ();
206
209
$ tokenStorage
207
210
->expects ($ this ->any ())
@@ -241,7 +244,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
241
244
->willReturn ([['foo ' => 'bar ' , 'bar ' => 'baz ' ], null ])
242
245
;
243
246
244
- $ authenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
247
+ $ authenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
245
248
$ authenticatedToken
246
249
->expects ($ this ->any ())
247
250
->method ('isAuthenticated ' )
@@ -263,7 +266,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
263
266
$ tokenStorage ,
264
267
$ accessDecisionManager ,
265
268
$ accessMap ,
266
- $ this ->createMock (' Symfony\Component\Security\Core\Authentication\ AuthenticationManagerInterface' )
269
+ $ this ->createMock (AuthenticationManagerInterface::class )
267
270
);
268
271
269
272
$ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
0 commit comments