1212namespace Symfony \Component \Security \Http \Tests \Authentication ;
1313
1414use PHPUnit \Framework \TestCase ;
15+ use Psr \Log \LoggerInterface ;
16+ use Symfony \Component \HttpFoundation \ParameterBag ;
1517use Symfony \Component \HttpFoundation \RedirectResponse ;
18+ use Symfony \Component \HttpFoundation \Request ;
1619use Symfony \Component \HttpFoundation \Response ;
20+ use Symfony \Component \HttpFoundation \Session \SessionInterface ;
1721use Symfony \Component \HttpKernel \HttpKernelInterface ;
22+ use Symfony \Component \Security \Core \Exception \AuthenticationException ;
1823use Symfony \Component \Security \Core \Security ;
1924use Symfony \Component \Security \Http \Authentication \DefaultAuthenticationFailureHandler ;
25+ use Symfony \Component \Security \Http \HttpUtils ;
2026
2127class DefaultAuthenticationFailureHandlerTest extends TestCase
2228{
@@ -29,14 +35,14 @@ class DefaultAuthenticationFailureHandlerTest extends TestCase
2935
3036 protected function setUp (): void
3137 {
32- $ this ->httpKernel = $ this ->getMockBuilder (HttpKernelInterface::class)-> getMock ( );
33- $ this ->httpUtils = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Http \ HttpUtils::class)-> getMock ( );
34- $ this ->logger = $ this ->getMockBuilder (\ Psr \ Log \ LoggerInterface::class)-> getMock ( );
38+ $ this ->httpKernel = $ this ->createMock (HttpKernelInterface::class);
39+ $ this ->httpUtils = $ this ->createMock ( HttpUtils::class);
40+ $ this ->logger = $ this ->createMock ( LoggerInterface::class);
3541
36- $ this ->session = $ this ->getMockBuilder (\ Symfony \ Component \ HttpFoundation \ Session \ SessionInterface::class)-> getMock ( );
37- $ this ->request = $ this ->getMockBuilder (\ Symfony \ Component \ HttpFoundation \ Request::class)-> getMock ( );
42+ $ this ->session = $ this ->createMock ( SessionInterface::class);
43+ $ this ->request = $ this ->createMock ( Request::class);
3844 $ this ->request ->expects ($ this ->any ())->method ('getSession ' )->willReturn ($ this ->session );
39- $ this ->exception = $ this ->getMockBuilder (\ Symfony \ Component \ Security \ Core \ Exception \ AuthenticationException::class)->setMethods (['getMessage ' ])->getMock ();
45+ $ this ->exception = $ this ->getMockBuilder (AuthenticationException::class)->setMethods (['getMessage ' ])->getMock ();
4046 }
4147
4248 public function testForward ()
@@ -183,8 +189,8 @@ public function testFailurePathParameterCanBeOverwritten()
183189
184190 private function getRequest ()
185191 {
186- $ request = $ this ->getMockBuilder (\ Symfony \ Component \ HttpFoundation \ Request::class)-> getMock ( );
187- $ request ->attributes = $ this ->getMockBuilder (\ Symfony \ Component \ HttpFoundation \ ParameterBag::class)-> getMock ( );
192+ $ request = $ this ->createMock ( Request::class);
193+ $ request ->attributes = $ this ->createMock ( ParameterBag::class);
188194
189195 return $ request ;
190196 }
0 commit comments