diff --git a/src/Illuminate/Testing/Fluent/Concerns/Matching.php b/src/Illuminate/Testing/Fluent/Concerns/Matching.php index 56fd3659a835..33ce0aa4a741 100644 --- a/src/Illuminate/Testing/Fluent/Concerns/Matching.php +++ b/src/Illuminate/Testing/Fluent/Concerns/Matching.php @@ -122,16 +122,26 @@ public function whereContains(string $key, $expected) } return $actual->containsStrict($search); - })->toArray(); - - PHPUnit::assertEmpty( - $missing, - sprintf( - 'Property [%s] does not contain [%s].', - $key, - implode(', ', array_values($missing)) - ) - ); + }); + + if ($missing->whereInstanceOf('Closure')->isNotEmpty()) { + PHPUnit::assertEmpty( + $missing->toArray(), + sprintf( + 'Property [%s] does not contain a value that passes the truth test within the given closure.', + $key, + ) + ); + } else { + PHPUnit::assertEmpty( + $missing->toArray(), + sprintf( + 'Property [%s] does not contain [%s].', + $key, + implode(', ', array_values($missing->toArray())) + ) + ); + } return $this; }