feat(store): finish ContributionStore and add typed entities

- Fix add()'s upsert SQL (was invalid SQL from typos) and use it for
  the new merge() as well.
- Fix remove()'s missing FROM keyword and drop the unindexed LIKE scan
  in favor of an exact match.
- Add latestDate(), all() with optional sinceDays filtering, and
  prune() with a retention-day cutoff.
- Add Contribution (immutable value object) and ContributionCollection
  (IteratorAggregate + Countable) so all() returns something typed
  instead of a raw date => count array.
- Cover all of the above with unit tests against an in-memory SQLite
  database.
This commit is contained in:
2026-07-11 16:46:21 +02:00
parent 885dec357e
commit 9087f91855
6 changed files with 296 additions and 22 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace App\Tests\Unit\Entity;
use App\Entity\Contribution;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
final class ContributionTest extends TestCase
{
#[Test]
public function it_exposes_provider_date_and_count(): void
{
$contribution = new Contribution('github', 1_700_000_000, 4);
$this->assertSame('github', $contribution->provider);
$this->assertSame(1_700_000_000, $contribution->date);
$this->assertSame(4, $contribution->count);
}
}