move_detect/server/tests/WiringSmokeTest.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

31 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests;
use App\Http\{Router, Request, Response};
use PHPUnit\Framework\TestCase;
final class WiringSmokeTest extends TestCase
{
public function testAllRoutesRegisteredAndDispatch(): void {
$r = new Router();
$paths = [
['POST', '/api/events'], ['POST', '/api/heartbeat'], ['GET', '/api/config'],
['POST', '/login'], ['POST', '/logout'], ['GET', '/api/events'],
['GET', '/events/{id}'], ['POST', '/events/{id}/ack'], ['GET', '/events/{id}/view'],
['GET', '/api/zones/{camera}'], ['POST', '/api/zones'],
['POST', '/api/zones/{id}/delete'], ['GET', '/snap/{uuid}'],
];
foreach ($paths as [$m, $p]) $r->add($m, $p, fn() => Response::json(['route' => $p]));
$this->assertSame(200, $r->dispatch(new Request('GET', '/events/9', [], '', [], []))->status());
$this->assertSame(200, $r->dispatch(new Request('GET', '/snap/abc', [], '', [], []))->status());
$this->assertSame(404, $r->dispatch(new Request('DELETE', '/api/events', [], '', [], []))->status());
// The 3-segment view route must resolve to itself, NOT be swallowed by the
// 2-segment /events/{id} JSON route (they are registered in that order).
$twoSeg = $r->dispatch(new Request('GET', '/events/9', [], '', [], []));
$this->assertSame('/events/{id}', json_decode($twoSeg->body(), true)['route']);
$viewSeg = $r->dispatch(new Request('GET', '/events/9/view', [], '', [], []));
$this->assertSame(200, $viewSeg->status());
$this->assertSame('/events/{id}/view', json_decode($viewSeg->body(), true)['route']);
}
}