@@ -113,7 +113,7 @@ public function testAuthorizeWithoutUser()
113113
114114 $ controller = new ServerController (...$ parameters );
115115
116- $ expected = new JSONResponse ('Authorization required ' , 401 );
116+ $ expected = new JSONResponse ('Authorization required ' , Http:: STATUS_UNAUTHORIZED );
117117 $ actual = $ controller ->authorize ();
118118
119119 $ this ->assertEquals ($ expected , $ actual );
@@ -135,7 +135,7 @@ public function testAuthorizeWithoutValidToken()
135135 $ controller = new ServerController (...$ parameters );
136136
137137 $ actual = $ controller ->authorize ();
138- $ expected = new JSONResponse ('Bad request, does not contain valid token ' , 400 );
138+ $ expected = new JSONResponse ('Bad request, does not contain valid token ' , Http:: STATUS_BAD_REQUEST );
139139
140140 $ this ->assertEquals ($ expected , $ actual );
141141 }
@@ -164,7 +164,7 @@ public function testAuthorizeWithoutApprovedClient()
164164 $ controller = new ServerController (...$ parameters );
165165
166166 $ actual = $ controller ->authorize ();
167- $ expected = new JSONResponse ('Approval required ' , 302 , ['Location ' => '' ]);
167+ $ expected = new JSONResponse ('Approval required ' , Http:: STATUS_FOUND , ['Location ' => '' ]);
168168
169169 $ this ->assertEquals ($ expected , $ actual );
170170 }
@@ -203,25 +203,24 @@ public function testAuthorizeWithApprovedClient()
203203 'headers ' => [
204204 'Cache-Control ' => 'no-cache, no-store, must-revalidate ' ,
205205 'Content-Security-Policy ' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' " ,
206+ 'Content-Type ' => 'application/json; charset=utf-8 ' ,
206207 'Feature-Policy ' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none' " ,
207208 'X-Robots-Tag ' => 'noindex, nofollow ' ,
208- 'Content-Type ' => 'application/json; charset=utf-8 ' ,
209-
210209 ],
211- 'status ' => 302 ,
210+ 'status ' => Http:: STATUS_FOUND ,
212211 ];
213212
214- $ headers = $ response ->getHeaders ();
215- $ location = $ headers ['Location ' ];
216- // Not comparing time-sensitive data
217- unset($ headers ['X-Request-Id ' ], $ headers ['Location ' ]);
218-
219213 $ actual = [
220214 'data ' => $ response ->getData (),
221- 'headers ' => $ headers ,
215+ 'headers ' => $ response -> getHeaders () ,
222216 'status ' => $ response ->getStatus (),
223217 ];
224218
219+ $ location = $ actual ['headers ' ]['Location ' ];
220+
221+ // Not comparing time-sensitive data
222+ unset($ actual ['headers ' ]['X-Request-Id ' ], $ actual ['headers ' ]['Location ' ]);
223+
225224 $ this ->assertEquals ($ expected , $ actual );
226225
227226 // @TODO: Move $location assert to a separate test
@@ -236,8 +235,8 @@ public function testAuthorizeWithApprovedClient()
236235 'host ' => 'mock.client ' ,
237236 'path ' => '/redirect ' ,
238237 'fragment ' => [
239- 'token_type ' => 'Bearer ' ,
240- 'expires_in ' => '3600 ' ,
238+ 'token_type ' => 'Bearer ' ,
239+ 'expires_in ' => '3600 ' ,
241240 ],
242241 ], $ url );
243242 }
0 commit comments