Skip to content

Commit

Permalink
Updated test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ash-jc-allen committed Apr 19, 2021
1 parent c0a82d8 commit 3c4f386
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/Support/SupportLazyCollectionIsLazyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Support;

use Illuminate\Collections\MultipleItemsFoundException;
use Illuminate\Support\LazyCollection;
use PHPUnit\Framework\TestCase;
use stdClass;
Expand Down Expand Up @@ -979,13 +980,29 @@ public function testSomeIsLazy()

public function testSoleIsLazy()
{
$data = $this->make([['a' => 1], ['a' => 2], ['a' => 3]]);
$this->assertEnumerates(2, function ($collection) {
try {
$collection->sole();
} catch (MultipleItemsFoundException $e) {
//
}
});

$this->assertEnumeratesCollection($data, 3, function ($collection) {
$this->assertEnumeratesOnce(function ($collection) {
$collection->sole(function ($item) {
return $item['a'] === 2;
return $item === 1;
});
});

$this->assertEnumerates(4, function ($collection) {
try {
$collection->sole(function ($item) {
return $item % 2 === 0;
});
} catch (MultipleItemsFoundException $e) {
//
}
});
}

public function testSortIsLazy()
Expand Down

0 comments on commit 3c4f386

Please sign in to comment.