Skip to content

Commit 2970dab

Browse files
committed
improve support for arrays on assertJsonValidationErrors
1 parent 87eb9a0 commit 2970dab

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/Illuminate/Foundation/Testing/TestResponse.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,13 @@ public function assertJsonValidationErrors($errors)
657657
);
658658

659659
if (! is_int($key)) {
660-
PHPUnit::assertStringContainsString(
661-
$value,
662-
$jsonErrors[$key],
660+
foreach (Arr::wrap($jsonErrors[$key]) as $jsonErrorMessage) {
661+
if (Str::contains($jsonErrorMessage, $value)) {
662+
return $this;
663+
}
664+
}
665+
666+
PHPUnit::fail(
663667
"Failed to find a validation error in the response for key and message: '$key' => '$value'".PHP_EOL.PHP_EOL.$errorMessage
664668
);
665669
}

0 commit comments

Comments
 (0)