Browse Source

Fix issue where RouterBuilder::scope() would not allow 2 arguments.

mark_story 11 years ago
parent
commit
817cc77821
2 changed files with 7 additions and 1 deletions
  1. 1 1
      src/Routing/RouteBuilder.php
  2. 6 0
      tests/TestCase/Routing/RouteBuilderTest.php

+ 1 - 1
src/Routing/RouteBuilder.php

@@ -484,7 +484,7 @@ class RouteBuilder {
  * @return void
  * @throws \InvalidArgumentException when there is no callable parameter.
  */
-	public function scope($path, $params, $callback) {
+	public function scope($path, $params, $callback = null) {
 		if ($callback === null) {
 			$callback = $params;
 			$params = [];

+ 6 - 0
tests/TestCase/Routing/RouteBuilderTest.php

@@ -419,6 +419,12 @@ class RouteBuilderTest extends TestCase {
 			$this->assertEquals('/api/v1', $routes->path());
 			$this->assertEquals(['prefix' => 'api', 'version' => 1], $routes->params());
 		});
+
+		$routes = new RouteBuilder($this->collection, '/api', ['prefix' => 'api']);
+		$routes->scope('/v1', function($routes) {
+			$this->assertEquals('/api/v1', $routes->path());
+			$this->assertEquals(['prefix' => 'api'], $routes->params());
+		});
 	}
 
 }