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