expectException(RuntimeException::class); $collection->getPath('nonexistent'); } /** @test */ public function it_properly_processes_a_simple_route_with_no_parameters() { $collection = new RouteCollection(); // We can use anything for the handler since we're only testing getPath $collection->addRoute('GET', '/custom/route', 'custom', ''); $this->assertEquals('/custom/route', $collection->getPath('custom')); } /** @test */ public function it_properly_processes_a_route_with_all_parameters_required() { $collection = new RouteCollection(); // We can use anything for the handler since we're only testing getPath $collection->addRoute('GET', '/custom/{route}/{has}/{parameters}', 'custom', ''); $this->assertEquals('/custom/something/something_else/anything_else', $collection->getPath('custom', [ 'route' => 'something', 'has' => 'something_else', 'parameters' => 'anything_else' ])); } /** @test */ public function it_works_if_optional_parameters_are_missing() { $collection = new RouteCollection(); // We can use anything for the handler since we're only testing getPath $collection->addRoute('GET', '/custom/{route}[/{has}]', 'custom', ''); $this->assertEquals('/custom/something', $collection->getPath('custom', [ 'route' => 'something' ])); } /** @test */ public function it_works_with_optional_parameters() { $collection = new RouteCollection(); // We can use anything for the handler since we're only testing getPath $collection->addRoute('GET', '/custom/{route}[/{has}]', 'custom', ''); $this->assertEquals('/custom/something/something_else', $collection->getPath('custom', [ 'route' => 'something', 'has' => 'something_else' ])); } }