Browse Source

Fix docs and add missing test coverage.

mark_story 11 years ago
parent
commit
7cb51d7d77
2 changed files with 15 additions and 9 deletions
  1. 4 1
      src/Routing/RouteCollection.php
  2. 11 8
      tests/TestCase/Routing/RouteCollectionTest.php

+ 4 - 1
src/Routing/RouteCollection.php

@@ -55,8 +55,11 @@ class RouteCollection {
 /**
  * Add a route to the collection.
  *
+ * @param \Cake\Routing\Route\Route $route The route object to add.
+ * @param array $options Addtional options for the route. Primarily for the
+ *   `_name` option, which enables named routes.
  */
-	public function add(Route $route, $options) {
+	public function add(Route $route, $options = []) {
 		$this->_routes[] = $route;
 
 		// Explicit names

+ 11 - 8
tests/TestCase/Routing/RouteCollectionTest.php

@@ -195,17 +195,20 @@ class RouteCollectionTest extends TestCase {
 	}
 
 /**
- * Test adding with an error
- */
-	public function testAdd() {
-	}
-
-/**
- * Test the routes() method.
+ * Test the add() and routes() method.
  *
  * @return void
  */
-	public function testRoutes() {
+	public function testAddingRoutes() {
+		$one = new Route('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
+		$two = new Route('/', ['controller' => 'Dashboards', 'action' => 'display']);
+		$this->collection->add($one);
+		$this->collection->add($two);
+
+		$routes = $this->collection->routes();
+		$this->assertCount(2, $routes);
+		$this->assertSame($one, $routes[0]);
+		$this->assertSame($two, $routes[1]);
 	}
 
 }