Add unit test for count method

This commit is contained in:
Daniel Winning 2025-04-09 02:48:30 +01:00
parent 7cc6e66313
commit 44030846dd

View file

@ -28,6 +28,13 @@ class CollectionTest extends TestCase
$this->assertEquals($expectedResult, $collection->toArray()); $this->assertEquals($expectedResult, $collection->toArray());
} }
#[DataProvider('countDataProvider')]
public function testCount(array $items, int $expectedResult): void
{
$collection = new Collection($items);
$this->assertEquals($expectedResult, $collection->count());
}
public static function addDataProvider(): array public static function addDataProvider(): array
{ {
return [ return [
@ -69,4 +76,22 @@ class CollectionTest extends TestCase
], ],
]; ];
} }
public static function countDataProvider(): array
{
return [
[
'items' => ['A', 'B', 'C'],
'expectedResult' => 3,
],
[
'items' => [],
'expectedResult' => 0,
],
[
'items' => [1, 2, 3, 4, 5],
'expectedResult' => 5,
],
];
}
} }