Browse Source

Add tests for Route::staticPath().

mark_story 11 years ago
parent
commit
ae6589874d
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/TestCase/Routing/Route/RouteTest.php

+ 20 - 0
tests/TestCase/Routing/Route/RouteTest.php

@@ -68,6 +68,7 @@ class RouteTest extends TestCase {
 		$this->assertRegExp($result, '/posts/super_delete');
 		$this->assertNotRegExp($result, '/posts');
 		$this->assertNotRegExp($result, '/posts/super_delete/1');
+		$this->assertSame($result, $route->compile());
 
 		$route = new Route('/posts/foo:id', array('controller' => 'posts', 'action' => 'view'));
 		$result = $route->compile();
@@ -934,4 +935,23 @@ class RouteTest extends TestCase {
 		$this->assertEquals($expected, $result);
 	}
 
+/**
+ * Test getting the static path for a route.
+ *
+ * @return void
+ */
+	public function testStaticPath() {
+		$route = new Route('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
+		$this->assertEquals('/pages/', $route->staticPath());
+
+		$route = new Route('/pages/:id/*', ['controller' => 'Pages', 'action' => 'display']);
+		$this->assertEquals('/pages/', $route->staticPath());
+
+		$route = new Route('/:controller/:action/*');
+		$this->assertEquals('/', $route->staticPath());
+
+		$route = new Route('/books/reviews', ['controller' => 'Reviews', 'action' => 'index']);
+		$this->assertEquals('/books/reviews', $route->staticPath());
+	}
+
 }