diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 0e1eaf2..9fba560 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -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()); + } }