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 \Authentication \Token \UsernamePasswordToken ;
22
23
use Symfony \Component \Security \Core \Authorization \AccessDecisionManagerInterface ;
23
24
use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
25
+ use Symfony \Component \Security \Core \Exception \AuthenticationCredentialsNotFoundException ;
24
26
use Symfony \Component \Security \Core \User \User ;
25
27
use Symfony \Component \Security \Http \AccessMapInterface ;
26
28
use Symfony \Component \Security \Http \Event \LazyResponseEvent ;
@@ -30,7 +32,7 @@ class AccessListenerTest extends TestCase
30
32
{
31
33
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess ()
32
34
{
33
- $ this ->expectException (\ Symfony \ Component \ Security \ Core \ Exception \ AccessDeniedException::class);
35
+ $ this ->expectException (AccessDeniedException::class);
34
36
$ request = new Request ();
35
37
36
38
$ accessMap = $ this ->getMockBuilder (AccessMapInterface::class)->getMock ();
@@ -41,7 +43,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
41
43
->willReturn ([['foo ' => 'bar ' ], null ])
42
44
;
43
45
44
- $ token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
46
+ $ token = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
45
47
$ token
46
48
->expects ($ this ->any ())
47
49
->method ('isAuthenticated ' )
@@ -85,14 +87,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
85
87
->willReturn ([['foo ' => 'bar ' ], null ])
86
88
;
87
89
88
- $ notAuthenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
90
+ $ notAuthenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
89
91
$ notAuthenticatedToken
90
92
->expects ($ this ->any ())
91
93
->method ('isAuthenticated ' )
92
94
->willReturn (false )
93
95
;
94
96
95
- $ authenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
97
+ $ authenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
96
98
$ authenticatedToken
97
99
->expects ($ this ->any ())
98
100
->method ('isAuthenticated ' )
@@ -149,7 +151,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
149
151
->willReturn ([null , null ])
150
152
;
151
153
152
- $ token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
154
+ $ token = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
153
155
$ token
154
156
->expects ($ this ->never ())
155
157
->method ('isAuthenticated ' )
@@ -204,7 +206,7 @@ public function testHandleWhenAccessMapReturnsEmptyAttributes()
204
206
205
207
public function testHandleWhenTheSecurityTokenStorageHasNoToken ()
206
208
{
207
- $ this ->expectException (\ Symfony \ Component \ Security \ Core \ Exception \ AuthenticationCredentialsNotFoundException::class);
209
+ $ this ->expectException (AuthenticationCredentialsNotFoundException::class);
208
210
$ tokenStorage = $ this ->getMockBuilder (TokenStorageInterface::class)->getMock ();
209
211
$ tokenStorage
210
212
->expects ($ this ->any ())
@@ -320,7 +322,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
320
322
->willReturn ([['foo ' => 'bar ' , 'bar ' => 'baz ' ], null ])
321
323
;
322
324
323
- $ authenticatedToken = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)->getMock ();
325
+ $ authenticatedToken = $ this ->getMockBuilder (TokenInterface::class)->getMock ();
324
326
$ authenticatedToken
325
327
->expects ($ this ->any ())
326
328
->method ('isAuthenticated ' )
@@ -342,7 +344,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
342
344
$ tokenStorage ,
343
345
$ accessDecisionManager ,
344
346
$ accessMap ,
345
- $ this ->createMock (' Symfony\Component\Security\Core\Authentication\ AuthenticationManagerInterface' )
347
+ $ this ->createMock (AuthenticationManagerInterface::class )
346
348
);
347
349
348
350
$ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
0 commit comments