Skip to content

Commit

Permalink
Add tests for filter and without methods
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshi2889 <rick.2889@gmail.com>
  • Loading branch information
NanoSector committed Jun 28, 2017
1 parent bf97b49 commit e4da648
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,32 @@ public function testInvalidType()
$this->expectException(InvalidArgumentException::class);
$collection->offsetSet('test', 10);
}

public function testFilter()
{
$initialValues = ['Test', 'ing', 'something', 'else'];
$collection = new Collection($this->getStringValidatorClosure(), $initialValues);

$filteredCollection = $collection->filter(function (string $value)
{
return $value != 'else';
});

self::assertEquals(['Test', 'ing', 'something'], $filteredCollection->values());
self::assertEquals(3, $filteredCollection->count());
}

public function testWithout()
{
$initialValues = ['Test', 'ing', 'something', 'else'];
$collection = new Collection($this->getStringValidatorClosure(), $initialValues);

$filteredCollection = $collection->without(function (string $value)
{
return $value != 'else';
});

self::assertEquals(['else'], $filteredCollection->values());
self::assertEquals(1, $filteredCollection->count());
}
}

0 comments on commit e4da648

Please sign in to comment.