Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

Commit

Permalink
Add tests for any and improve tests for first in Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoboss committed Jun 5, 2020
1 parent 365eb49 commit a9b584d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/Unit/Container/CollectionTest.php
Expand Up @@ -50,6 +50,10 @@ public function testFirst()
'ghi',
]);

$first = $collection->first();

static::assertEquals('abc', $first);

$first = $collection->first(function ($val) {
return strpos($val, 'e') !== false;
});
Expand Down Expand Up @@ -148,4 +152,17 @@ public function testAsArray()

static::assertEquals(["test", "moo", "ooo"], $arr);
}

public function testAny()
{
$collection = new Collection(["foo", "bar", "faz", "baz"]);

static::assertTrue($collection->any());
static::assertTrue($collection->any(fn($v) => str_contains($v, "a")));
static::assertFalse($collection->any(fn($v) => str_contains($v, "e")));

$collection->clear();

static::assertFalse($collection->any());
}
}

0 comments on commit a9b584d

Please sign in to comment.