@@ -204,25 +204,19 @@ public function testHTTPSuccess(): void
204
204
205
205
echo \implode ("\n" , $ output );
206
206
207
- # Some languages deserialize JSON with sorted keys, other not.
208
- # We use this custom assertion to normalise the lines with JSON before comparison.
209
- $ this ->assertEqualsWithJsonLines ($ this ->expectedOutput , $ output );
207
+ $ this ->assertEquals ([], \array_diff (
208
+ $ this ->normalizeConsoleLines ($ output ),
209
+ $ this ->normalizeConsoleLines ($ this ->expectedOutput )
210
+ ));
210
211
}
211
212
212
- private function assertEqualsWithJsonLines ($ expectedLines , $ actualLines )
213
- {
214
- for ($ i = 0 ; $ i < \count ($ expectedLines ); $ i ++) {
215
- $ this ->assertArrayHasKey ($ i , $ actualLines , "Missing line {$ i }: {$ expectedLines [$ i ]}" );
216
-
217
- $ expectedLine = $ expectedLines [$ i ];
218
- $ actualLine = $ actualLines [$ i ];
219
-
220
- if (\str_starts_with ($ expectedLine , '{ ' )) {
221
- $ this ->assertEquals (\json_decode ($ expectedLine ), \json_decode ($ actualLine ));
222
- } else {
223
- $ this ->assertEquals ($ expectedLine , $ actualLine );
213
+ private function normalizeConsoleLines ($ lines ) {
214
+ return \array_map (function (string $ line ) {
215
+ if (\str_starts_with ($ line , '{ ' )) {
216
+ return \json_decode ($ line );
224
217
}
225
- }
218
+ return $ line ;
219
+ }, $ lines );
226
220
}
227
221
228
222
private function rmdirRecursive ($ dir ): void
0 commit comments