Skip to content

Commit

Permalink
Add integration test for route fluent methods.
Browse files Browse the repository at this point in the history
Simple integration test covering the new features.
  • Loading branch information
markstory committed May 31, 2017
1 parent df9ccde commit ebee462
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/TestCase/Routing/RouteBuilderTest.php
Expand Up @@ -882,4 +882,28 @@ public function testHttpMethods($method)
$route->defaults
);
}

/**
* Integration test for http method helpers and route fluent method
*
* @return void
*/
public function testHttpMethodIntegration()
{
$routes = new RouteBuilder($this->collection, '/');
$routes->scope('/', function ($routes) {
$routes->get('/faq/:page', ['controller' => 'Pages', 'action' => 'faq'], 'faq')
->setPatterns(['page' => '[a-z0-9_]+'])
->setHost('docs.example.com');

$routes->post('/articles/:id', ['controller' => 'Articles', 'action' => 'update'], 'article:update')
->setPatterns(['id' => '[0-9]+'])
->setPass(['id']);
});
$this->assertCount(2, $this->collection->routes());
$this->assertEquals(['faq', 'article:update'], array_keys($this->collection->named()));
$this->assertNotEmpty($this->collection->parse('/faq/things_you_know'));
$result = $this->collection->parse('/articles/123');
$this->assertEquals(['123'], $result['pass']);
}
}

0 comments on commit ebee462

Please sign in to comment.