move_detect/server/tests/RouterTest.php
유창욱 3f2823a764 refactor: rename cloud/ to server/ (cafe24 is web hosting, not cloud)
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.
2026-07-20 11:30:52 +09:00

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());
}
}