diff --git a/src/Illuminate/Foundation/Testing/TestResponse.php b/src/Illuminate/Foundation/Testing/TestResponse.php index 308a8feb1a82..50177d8a39d5 100644 --- a/src/Illuminate/Foundation/Testing/TestResponse.php +++ b/src/Illuminate/Foundation/Testing/TestResponse.php @@ -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 ); }