1212namespace Symfony \Component \Security \Http \Tests \Authentication ;
1313
1414use PHPUnit \Framework \TestCase ;
15+ use Symfony \Component \HttpFoundation \Request ;
1516use Symfony \Component \HttpFoundation \Response ;
1617use Symfony \Component \Security \Core \Authentication \SimpleAuthenticatorInterface ;
18+ use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
1719use Symfony \Component \Security \Core \Exception \AuthenticationException ;
1820use Symfony \Component \Security \Http \Authentication \AuthenticationFailureHandlerInterface ;
1921use Symfony \Component \Security \Http \Authentication \AuthenticationSuccessHandlerInterface ;
@@ -38,11 +40,11 @@ class SimpleAuthenticationHandlerTest extends TestCase
3840
3941 protected function setUp (): void
4042 {
41- $ this ->successHandler = $ this ->getMockBuilder (AuthenticationSuccessHandlerInterface::class)-> getMock ( );
42- $ this ->failureHandler = $ this ->getMockBuilder (AuthenticationFailureHandlerInterface::class)-> getMock ( );
43+ $ this ->successHandler = $ this ->createMock (AuthenticationSuccessHandlerInterface::class);
44+ $ this ->failureHandler = $ this ->createMock (AuthenticationFailureHandlerInterface::class);
4345
44- $ this ->request = $ this ->getMockBuilder (\ Symfony \ Component \ HttpFoundation \ Request::class)-> getMock ( );
45- $ this ->token = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Authentication \ Token \ TokenInterface::class)-> getMock ( );
46+ $ this ->request = $ this ->createMock ( Request::class);
47+ $ this ->token = $ this ->createMock ( TokenInterface::class);
4648 // No methods are invoked on the exception; we just assert on its class
4749 $ this ->authenticationException = new AuthenticationException ();
4850
@@ -51,7 +53,7 @@ protected function setUp(): void
5153
5254 public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler ()
5355 {
54- $ authenticator = $ this ->getMockBuilder (SimpleAuthenticatorInterface::class)-> getMock ( );
56+ $ authenticator = $ this ->createMock (SimpleAuthenticatorInterface::class);
5557
5658 $ this ->successHandler ->expects ($ this ->once ())
5759 ->method ('onAuthenticationSuccess ' )
@@ -69,7 +71,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
6971 $ this ->successHandler ->expects ($ this ->never ())
7072 ->method ('onAuthenticationSuccess ' );
7173
72- $ authenticator = $ this ->getMockForAbstractClass (\ Symfony \ Component \ Security \ Http \ Tests \ Authentication \ TestSuccessHandlerInterface::class);
74+ $ authenticator = $ this ->getMockForAbstractClass (TestSuccessHandlerInterface::class);
7375 $ authenticator ->expects ($ this ->once ())
7476 ->method ('onAuthenticationSuccess ' )
7577 ->with ($ this ->request , $ this ->token )
@@ -88,7 +90,7 @@ public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsRetur
8890 $ this ->successHandler ->expects ($ this ->never ())
8991 ->method ('onAuthenticationSuccess ' );
9092
91- $ authenticator = $ this ->getMockForAbstractClass (\ Symfony \ Component \ Security \ Http \ Tests \ Authentication \ TestSuccessHandlerInterface::class);
93+ $ authenticator = $ this ->getMockForAbstractClass (TestSuccessHandlerInterface::class);
9294 $ authenticator ->expects ($ this ->once ())
9395 ->method ('onAuthenticationSuccess ' )
9496 ->with ($ this ->request , $ this ->token )
@@ -105,7 +107,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
105107 ->with ($ this ->request , $ this ->token )
106108 ->willReturn ($ this ->response );
107109
108- $ authenticator = $ this ->getMockForAbstractClass (\ Symfony \ Component \ Security \ Http \ Tests \ Authentication \ TestSuccessHandlerInterface::class);
110+ $ authenticator = $ this ->getMockForAbstractClass (TestSuccessHandlerInterface::class);
109111 $ authenticator ->expects ($ this ->once ())
110112 ->method ('onAuthenticationSuccess ' )
111113 ->with ($ this ->request , $ this ->token )
@@ -119,7 +121,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
119121
120122 public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler ()
121123 {
122- $ authenticator = $ this ->getMockBuilder (SimpleAuthenticatorInterface::class)-> getMock ( );
124+ $ authenticator = $ this ->createMock (SimpleAuthenticatorInterface::class);
123125
124126 $ this ->failureHandler ->expects ($ this ->once ())
125127 ->method ('onAuthenticationFailure ' )
@@ -137,7 +139,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator()
137139 $ this ->failureHandler ->expects ($ this ->never ())
138140 ->method ('onAuthenticationFailure ' );
139141
140- $ authenticator = $ this ->getMockForAbstractClass (\ Symfony \ Component \ Security \ Http \ Tests \ Authentication \ TestFailureHandlerInterface::class);
142+ $ authenticator = $ this ->getMockForAbstractClass (TestFailureHandlerInterface::class);
141143 $ authenticator ->expects ($ this ->once ())
142144 ->method ('onAuthenticationFailure ' )
143145 ->with ($ this ->request , $ this ->authenticationException )
@@ -156,7 +158,7 @@ public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsRetur
156158 $ this ->failureHandler ->expects ($ this ->never ())
157159 ->method ('onAuthenticationFailure ' );
158160
159- $ authenticator = $ this ->getMockForAbstractClass (\ Symfony \ Component \ Security \ Http \ Tests \ Authentication \ TestFailureHandlerInterface::class);
161+ $ authenticator = $ this ->getMockForAbstractClass (TestFailureHandlerInterface::class);
160162 $ authenticator ->expects ($ this ->once ())
161163 ->method ('onAuthenticationFailure ' )
162164 ->with ($ this ->request , $ this ->authenticationException )
@@ -173,7 +175,7 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsRetu
173175 ->with ($ this ->request , $ this ->authenticationException )
174176 ->willReturn ($ this ->response );
175177
176- $ authenticator = $ this ->getMockForAbstractClass (\ Symfony \ Component \ Security \ Http \ Tests \ Authentication \ TestFailureHandlerInterface::class);
178+ $ authenticator = $ this ->getMockForAbstractClass (TestFailureHandlerInterface::class);
177179 $ authenticator ->expects ($ this ->once ())
178180 ->method ('onAuthenticationFailure ' )
179181 ->with ($ this ->request , $ this ->authenticationException )
0 commit comments