move_detect/cloud/tests/RepositoryContractTest.php
유창욱 4bbd28f95f fix(cloud): centralize test-double autoloading via composer files
Move InMemoryRepositories.php from require_once workaround to composer
files-autoload. Enables PSR-4 autoloading of test-double classes and
scales for 5+ future test files. All 8 tests pass with require_once removed.
2026-07-11 23:38:01 +09:00

31 lines
1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests;
use App\Tests\Support\{InMemoryNonceRepository, InMemoryEventRepository, InMemoryRateLimiter};
use PHPUnit\Framework\TestCase;
final class RepositoryContractTest extends TestCase
{
public function testNonceRememberThenSeen(): void
{
$r = new InMemoryNonceRepository();
$this->assertFalse($r->seen('n1'));
$r->remember('n1', 999);
$this->assertTrue($r->seen('n1'));
}
public function testEventInsertAndRecent(): void
{
$r = new InMemoryEventRepository();
$id = $r->insert(['severity' => 'high', 'event_type' => 'fall']);
$this->assertSame(1, $id);
$this->assertCount(1, $r->recent(10, null));
$this->assertCount(0, $r->recent(10, 'critical'));
}
public function testRateLimiterIncrements(): void
{
$r = new InMemoryRateLimiter();
$this->assertSame(1, $r->hit('dev', 100));
$this->assertSame(2, $r->hit('dev', 100));
$this->assertSame(1, $r->hit('dev', 160));
}
}