The PHP app runs on Cafe24 shared web hosting -- calling it 'cloud' was misleading. Renames the directory, the edge client module, and every doc/script/identifier that used the term. - cloud/ -> server/ (incl. server/deploy/build_cafe24_package.sh paths) - edge/cloudclient.py -> edge/serverclient.py, CloudClient -> ServerClient - cloud/docs/cloud-deploy.md -> server/docs/server-deploy.md - CLOUD_* env/config keys -> SERVER_* - tests renamed to match Tests: PHP 109 pass (4 skipped), pytest 167 pass. dist/ regenerated.
31 lines
1 KiB
PHP
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));
|
|
}
|
|
}
|