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']); } }