/** * Test that parsing checks all the related path scopes. * * @return void */ public function testParseFallback() { $routes = new RouteBuilder($this->collection, '/', []); $routes->resources('Articles'); $routes->connect('/:controller', ['action' => 'index'], [], ['routeClass' => 'InflectedRoute']); $routes->connect('/:controller/:action', [], ['routeClass' => 'InflectedRoute']); $result = $this->collection->parse('/articles/add'); $expected = ['controller' => 'Articles', 'action' => 'add', 'plugin' => null, 'pass' => []]; $this->assertEquals($expected, $result); }
/** * Test nesting resources * * @return void */ public function testResourcesNested() { $routes = new RouteBuilder($this->collection, '/api', ['prefix' => 'api']); $routes->resources('Articles', function ($routes) { $this->assertEquals('/api/articles/', $routes->path()); $this->assertEquals(['prefix' => 'api'], $routes->params()); $routes->resources('Comments'); $route = $this->collection->routes()[6]; $this->assertEquals('/api/articles/:article_id/comments', $route->template); }); }