19
19
use Symfony \Component \Security \Core \Authentication \Token \NullToken ;
20
20
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorage ;
21
21
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
22
+ use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
22
23
use Symfony \Component \Security \Core \Authentication \Token \UsernamePasswordToken ;
23
24
use Symfony \Component \Security \Core \Authorization \AccessDecisionManagerInterface ;
24
25
use Symfony \Component \Security \Core \Authorization \Voter \AuthenticatedVoter ;
25
26
use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
27
+ use Symfony \Component \Security \Core \Exception \AuthenticationCredentialsNotFoundException ;
26
28
use Symfony \Component \Security \Core \User \User ;
27
29
use Symfony \Component \Security \Http \AccessMapInterface ;
28
30
use Symfony \Component \Security \Http \Event \LazyResponseEvent ;
@@ -32,7 +34,7 @@ class AccessListenerTest extends TestCase
32
34
{
33
35
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess ()
34
36
{
35
- $ this ->expectException (\ Symfony \ Component \ Security \ Core \ Exception \ AccessDeniedException::class);
37
+ $ this ->expectException (AccessDeniedException::class);
36
38
$ request = new Request ();
37
39
38
40
$ accessMap = $ this ->getMockBuilder (AccessMapInterface::class)->getMock ();
@@ -43,7 +45,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
43
45
->willReturn ([['foo ' => 'bar ' ], null ])
44
46
;
45
47
46
- $ token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
48
+ $ token = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
47
49
$ token
48
50
->expects ($ this ->any ())
49
51
->method ('isAuthenticated ' )
@@ -87,14 +89,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
87
89
->willReturn ([['foo ' => 'bar ' ], null ])
88
90
;
89
91
90
- $ notAuthenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
92
+ $ notAuthenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
91
93
$ notAuthenticatedToken
92
94
->expects ($ this ->any ())
93
95
->method ('isAuthenticated ' )
94
96
->willReturn (false )
95
97
;
96
98
97
- $ authenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
99
+ $ authenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
98
100
$ authenticatedToken
99
101
->expects ($ this ->any ())
100
102
->method ('isAuthenticated ' )
@@ -151,7 +153,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
151
153
->willReturn ([null , null ])
152
154
;
153
155
154
- $ token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
156
+ $ token = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
155
157
$ token
156
158
->expects ($ this ->never ())
157
159
->method ('isAuthenticated ' )
@@ -206,7 +208,7 @@ public function testHandleWhenAccessMapReturnsEmptyAttributes()
206
208
207
209
public function testHandleWhenTheSecurityTokenStorageHasNoToken ()
208
210
{
209
- $ this ->expectException (\ Symfony \ Component \ Security \ Core \ Exception \ AuthenticationCredentialsNotFoundException::class);
211
+ $ this ->expectException (AuthenticationCredentialsNotFoundException::class);
210
212
$ tokenStorage = $ this ->getMockBuilder (TokenStorageInterface::class)->getMock ();
211
213
$ tokenStorage
212
214
->expects ($ this ->any ())
@@ -336,7 +338,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
336
338
->willReturn ([['foo ' => 'bar ' , 'bar ' => 'baz ' ], null ])
337
339
;
338
340
339
- $ authenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
341
+ $ authenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
340
342
$ authenticatedToken
341
343
->expects ($ this ->any ())
342
344
->method ('isAuthenticated ' )
@@ -358,7 +360,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
358
360
$ tokenStorage ,
359
361
$ accessDecisionManager ,
360
362
$ accessMap ,
361
- $ this ->createMock (' Symfony\Component\Security\Core\Authentication\ AuthenticationManagerInterface' )
363
+ $ this ->createMock (AuthenticationManagerInterface::class )
362
364
);
363
365
364
366
$ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
0 commit comments