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.
25 lines
991 B
PHP
25 lines
991 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace App\Tests;
|
|
use App\Http\{Router, Request, Response};
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class RouterTest extends TestCase
|
|
{
|
|
public function testMatchAndParams(): void {
|
|
$r = new Router();
|
|
$r->add('GET', '/events/{id}', fn(Request $req, array $p) => Response::json(['id' => $p['id']]));
|
|
$res = $r->dispatch(new Request('GET', '/events/42', [], '', [], []));
|
|
$this->assertSame(200, $res->status());
|
|
$this->assertSame(['id' => '42'], json_decode($res->body(), true));
|
|
}
|
|
public function testUnmatchedIs404(): void {
|
|
$r = new Router();
|
|
$this->assertSame(404, $r->dispatch(new Request('GET', '/nope', [], '', [], []))->status());
|
|
}
|
|
public function testMethodMismatchIs404(): void {
|
|
$r = new Router();
|
|
$r->add('POST', '/x', fn() => Response::text('ok'));
|
|
$this->assertSame(404, $r->dispatch(new Request('GET', '/x', [], '', [], []))->status());
|
|
}
|
|
}
|