Skip to content

Commit ae65898

Browse files
committed
Add tests for Route::staticPath().
1 parent 12c5f5b commit ae65898

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/TestCase/Routing/Route/RouteTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function testBasicRouteCompiling() {
6868
$this->assertRegExp($result, '/posts/super_delete');
6969
$this->assertNotRegExp($result, '/posts');
7070
$this->assertNotRegExp($result, '/posts/super_delete/1');
71+
$this->assertSame($result, $route->compile());
7172

7273
$route = new Route('/posts/foo:id', array('controller' => 'posts', 'action' => 'view'));
7374
$result = $route->compile();
@@ -934,4 +935,23 @@ public function testUTF8PatternOnSection() {
934935
$this->assertEquals($expected, $result);
935936
}
936937

938+
/**
939+
* Test getting the static path for a route.
940+
*
941+
* @return void
942+
*/
943+
public function testStaticPath() {
944+
$route = new Route('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
945+
$this->assertEquals('/pages/', $route->staticPath());
946+
947+
$route = new Route('/pages/:id/*', ['controller' => 'Pages', 'action' => 'display']);
948+
$this->assertEquals('/pages/', $route->staticPath());
949+
950+
$route = new Route('/:controller/:action/*');
951+
$this->assertEquals('/', $route->staticPath());
952+
953+
$route = new Route('/books/reviews', ['controller' => 'Reviews', 'action' => 'index']);
954+
$this->assertEquals('/books/reviews', $route->staticPath());
955+
}
956+
937957
}

0 commit comments

Comments
 (0)