Skip to content

Commit e9bd785

Browse files
committed
test: fix custom assertion
1 parent 991fdef commit e9bd785

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/Base.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,15 @@ public function testHTTPSuccess(): void
209209
$this->assertEqualsWithJsonLines($this->expectedOutput, $output);
210210
}
211211

212-
private function isJsonString(string $str)
213-
{
214-
return \str_starts_with($str, '{');
215-
}
216-
217212
private function assertEqualsWithJsonLines($expectedLines, $actualLines)
218213
{
219-
for ($i = 0; $i <= 10; $i++) {
220-
$expectedLine = $expectedLines[0];
221-
$actualLine = $actualLines[0];
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];
222219

223-
if ($this->isJsonString($expectedLine)) {
220+
if (\str_starts_with($expectedLine, '{')) {
224221
$this->assertEquals(\json_decode($expectedLine), \json_decode($actualLine));
225222
} else {
226223
$this->assertEquals($expectedLine, $actualLine);

0 commit comments

Comments
 (0)