get('/users/{id}', fn($params) => 'handler', [], 'user_show'); $result = $router->dispatch('GET', '/users/42'); $this->assertNotNull($result); $handler = $result['handler']; $this->assertIsCallable($handler); $this->assertSame('handler', ($handler)(['id' => '42'])); $this->assertEquals(['id' => '42'], $result['params']); } public function testUrlGeneration(): void { $router = new Router(); $router->get('/posts/{slug}', fn() => null, [], 'post_show'); $url = $router->url('post_show', ['slug' => 'hello-world']); $this->assertSame('/posts/hello-world', $url); } }