1111use ItkDev \OpenIdConnectBundle \Security \OpenIdConfigurationProviderManager ;
1212use PHPUnit \Framework \Attributes \DataProvider ;
1313use PHPUnit \Framework \TestCase ;
14- use Symfony \Component \HttpFoundation \InputBag ;
15- use Symfony \Component \HttpFoundation \RedirectResponse ;
1614use Symfony \Component \HttpFoundation \Request ;
1715use Symfony \Component \HttpFoundation \Session \SessionInterface ;
1816use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
@@ -39,8 +37,7 @@ public function testLogin(): void
3937
4038 $ controller = $ this ->createController ($ mockProvider );
4139
42- $ stubRequest = $ this ->createStub (Request::class);
43- $ stubRequest ->query = new InputBag (['provider ' => 'test ' ]);
40+ $ request = new Request (query: ['provider ' => 'test ' ]);
4441 $ mockSession = $ this ->createMock (SessionInterface::class);
4542 $ matcher = $ this ->exactly (3 );
4643 $ mockSession
@@ -60,8 +57,7 @@ public function testLogin(): void
6057 }
6158 });
6259
63- $ response = $ controller ->login ($ stubRequest , $ mockSession , 'test ' );
64- $ this ->assertInstanceOf (RedirectResponse::class, $ response );
60+ $ response = $ controller ->login ($ request , $ mockSession , 'test ' );
6561 $ this ->assertSame ('https://test.com ' , $ response ->getTargetUrl ());
6662 }
6763
@@ -79,7 +75,7 @@ public function testUnknownProviderKeyMapsTo404(): void
7975 $ controller = new LoginController ($ mockProviderManager );
8076
8177 try {
82- $ controller ->login ($ this -> createStub ( Request::class ), $ this ->createStub (SessionInterface::class), 'bogus ' );
78+ $ controller ->login (new Request ( ), $ this ->createStub (SessionInterface::class), 'bogus ' );
8379 } catch (NotFoundHttpException $ thrown ) {
8480 $ this ->assertSame (404 , $ thrown ->getStatusCode ());
8581 $ this ->assertStringContainsString ('bogus ' , $ thrown ->getMessage ());
@@ -111,7 +107,7 @@ public function testUpstreamFailureMapsTo503(\Throwable $cause): void
111107 $ controller = $ this ->createController ($ stubProvider );
112108
113109 try {
114- $ controller ->login ($ this -> createStub ( Request::class ), $ this ->createStub (SessionInterface::class), 'test ' );
110+ $ controller ->login (new Request ( ), $ this ->createStub (SessionInterface::class), 'test ' );
115111 } catch (ServiceUnavailableHttpException $ thrown ) {
116112 $ this ->assertSame (503 , $ thrown ->getStatusCode ());
117113 $ this ->assertStringContainsString ('test ' , $ thrown ->getMessage ());
0 commit comments