44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace GitContributionGraph\Tests\Unit\Entity;
|
|
|
|
use GitContributionGraph\Entity\Contribution;
|
|
use GitContributionGraph\Entity\ContributionCollection;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ContributionCollectionTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function it_counts_zero_when_empty(): void
|
|
{
|
|
$collection = new ContributionCollection();
|
|
|
|
$this->assertCount(0, $collection);
|
|
}
|
|
|
|
#[Test]
|
|
public function it_counts_the_contributions_it_wraps(): void
|
|
{
|
|
$collection = new ContributionCollection(
|
|
new Contribution('github', 1_700_000_000, 1),
|
|
new Contribution('github', 1_700_086_400, 2),
|
|
);
|
|
|
|
$this->assertCount(2, $collection);
|
|
}
|
|
|
|
#[Test]
|
|
public function it_is_iterable_over_its_contributions(): void
|
|
{
|
|
$first = new Contribution('github', 1_700_000_000, 1);
|
|
$second = new Contribution('gitlab', 1_700_086_400, 2);
|
|
|
|
$collection = new ContributionCollection($first, $second);
|
|
|
|
$this->assertSame([$first, $second], iterator_to_array($collection));
|
|
}
|
|
}
|