From 37217d56ca38c407395bb98ef2532cafd86efa30 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 26 Oct 2021 15:15:57 -0500 Subject: [PATCH] fix bug with closure formatting --- .../Testing/Fluent/Concerns/Matching.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) 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; }