Skip to content

Commit

Permalink
improve support for arrays on assertJsonValidationErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 12, 2019
1 parent 87eb9a0 commit 2970dab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,13 @@ public function assertJsonValidationErrors($errors)
);

if (! is_int($key)) {
PHPUnit::assertStringContainsString(
$value,
$jsonErrors[$key],
foreach (Arr::wrap($jsonErrors[$key]) as $jsonErrorMessage) {
if (Str::contains($jsonErrorMessage, $value)) {
return $this;
}
}

PHPUnit::fail(
"Failed to find a validation error in the response for key and message: '$key' => '$value'".PHP_EOL.PHP_EOL.$errorMessage
);
}
Expand Down

0 comments on commit 2970dab

Please sign in to comment.