Skip to content

Commit

Permalink
Add getRouteCollection()
Browse files Browse the repository at this point in the history
This method will be used by the new hooks to create the initial builder
that is passed to the application's routing hook.
  • Loading branch information
markstory committed May 11, 2017
1 parent 870ec58 commit 9a5c31e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Routing/Router.php
Expand Up @@ -1059,6 +1059,16 @@ public static function routes()
return static::$_collection->routes();
}

/**
* Get the RouteCollection inside the Router
*
* @return \Cake\Routing\RouteCollection
*/
public static function getRouteCollection()
{
return static::$_collection;
}

/**
* Get a MiddlewareQueue of middleware that matches the provided path.
*
Expand Down
13 changes: 13 additions & 0 deletions tests/TestCase/Routing/RouterTest.php
Expand Up @@ -19,6 +19,7 @@
use Cake\Http\MiddlewareQueue;
use Cake\Http\ServerRequest;
use Cake\Http\ServerRequestFactory;
use Cake\Routing\RouteCollection;
use Cake\Routing\Router;
use Cake\Routing\Route\Route;
use Cake\TestSuite\TestCase;
Expand Down Expand Up @@ -3363,6 +3364,18 @@ public function testGetMatchingMiddleware()
$this->assertCount(1, $result);
}

/**
* Test getting the route collection
*
* @return void
*/
public function testGetRouteCollection()
{
$collection = Router::getRouteCollection();
$this->assertInstanceOf(RouteCollection::class, $collection);
$this->assertCount(0, $collection->routes());
}

/**
* Connect some fallback routes for testing router behavior.
*
Expand Down

0 comments on commit 9a5c31e

Please sign in to comment.