From fa91076bc55be9eaab70567063205e4bab292d70 Mon Sep 17 00:00:00 2001 From: Joseph Silber Date: Thu, 27 Aug 2020 22:00:42 -0400 Subject: [PATCH 1/2] Use `assertEnumeratesCollectionOnce`, for clearer test --- tests/Support/SupportLazyCollectionIsLazyTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Support/SupportLazyCollectionIsLazyTest.php b/tests/Support/SupportLazyCollectionIsLazyTest.php index 1abaa0146f36..94e8564abed7 100644 --- a/tests/Support/SupportLazyCollectionIsLazyTest.php +++ b/tests/Support/SupportLazyCollectionIsLazyTest.php @@ -39,10 +39,10 @@ public function testChunkWhileIsLazy() }); }); - $this->assertEnumeratesCollection($collection, 7, function ($collection) { + $this->assertEnumeratesCollectionOnce($collection, function ($collection) { $collection->chunkWhile(function ($current, $key, $chunk) { return $current === $chunk->last(); - })->take(7)->all(); + })->all(); }); } From d54f9e6326576dafe5caa3acd0864aa664119c71 Mon Sep 17 00:00:00 2001 From: Joseph Silber Date: Thu, 27 Aug 2020 22:02:10 -0400 Subject: [PATCH 2/2] Ensure `chunkWhile` enumerates the least amount of items necessary --- tests/Support/SupportLazyCollectionIsLazyTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Support/SupportLazyCollectionIsLazyTest.php b/tests/Support/SupportLazyCollectionIsLazyTest.php index 94e8564abed7..b61df7a6b632 100644 --- a/tests/Support/SupportLazyCollectionIsLazyTest.php +++ b/tests/Support/SupportLazyCollectionIsLazyTest.php @@ -39,6 +39,12 @@ public function testChunkWhileIsLazy() }); }); + $this->assertEnumeratesCollection($collection, 3, function ($collection) { + $collection->chunkWhile(function ($current, $key, $chunk) { + return $current === $chunk->last(); + })->first(); + }); + $this->assertEnumeratesCollectionOnce($collection, function ($collection) { $collection->chunkWhile(function ($current, $key, $chunk) { return $current === $chunk->last();