23 lines
1.1 KiB
PHP
23 lines
1.1 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', '/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());
|
|
}
|
|
}
|