Add unit test for count method
This commit is contained in:
parent
7cc6e66313
commit
44030846dd
1 changed files with 25 additions and 0 deletions
|
@ -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,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue