Skip to content

Commit 3c4f386

Browse files
committed
Updated test.
1 parent c0a82d8 commit 3c4f386

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tests/Support/SupportLazyCollectionIsLazyTest.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Tests\Support;
44

5+
use Illuminate\Collections\MultipleItemsFoundException;
56
use Illuminate\Support\LazyCollection;
67
use PHPUnit\Framework\TestCase;
78
use stdClass;
@@ -979,13 +980,29 @@ public function testSomeIsLazy()
979980

980981
public function testSoleIsLazy()
981982
{
982-
$data = $this->make([['a' => 1], ['a' => 2], ['a' => 3]]);
983+
$this->assertEnumerates(2, function ($collection) {
984+
try {
985+
$collection->sole();
986+
} catch (MultipleItemsFoundException $e) {
987+
//
988+
}
989+
});
983990

984-
$this->assertEnumeratesCollection($data, 3, function ($collection) {
991+
$this->assertEnumeratesOnce(function ($collection) {
985992
$collection->sole(function ($item) {
986-
return $item['a'] === 2;
993+
return $item === 1;
987994
});
988995
});
996+
997+
$this->assertEnumerates(4, function ($collection) {
998+
try {
999+
$collection->sole(function ($item) {
1000+
return $item % 2 === 0;
1001+
});
1002+
} catch (MultipleItemsFoundException $e) {
1003+
//
1004+
}
1005+
});
9891006
}
9901007

9911008
public function testSortIsLazy()

0 commit comments

Comments
 (0)