Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

add getRouter() function in Routers #134

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Router/AuraRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ private function createRouter()
);
}

/**
* @return Router
*/
public function getRouter()
{
return $this->router;
}

/**
* Add a route to the underlying router.
*
Expand Down
8 changes: 8 additions & 0 deletions src/Router/FastRouteRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ private function createRouter()
return new RouteCollector(new RouteParser, new RouteGenerator);
}

/**
* @return RouteCollector
*/
public function getRouter()
{
return $this->router;
}

/**
* Retrieve the dispatcher instance.
*
Expand Down
8 changes: 8 additions & 0 deletions src/Router/Zf2Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ private function createRouter()
return new TreeRouteStack();
}

/**
* @return TreeRouteStack
*/
public function getRouter()
{
return $this->zf2Router;
}

/**
* Create a successful RouteResult from the given RouteMatch.
*
Expand Down
6 changes: 6 additions & 0 deletions test/Router/AuraRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public function getRouter()
return new AuraRouter($this->auraRouter->reveal());
}

public function testGetAuraRouterRouter()
{
$router = $this->getRouter();
$this->assertSame($this->auraRouter->reveal(), $router->getRouter());
}

public function testAddingRouteProxiesToAuraRouter()
{
$route = new Route('/foo', 'foo', ['GET']);
Expand Down
6 changes: 6 additions & 0 deletions test/Router/FastRouteRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public function getRouter()
);
}

public function testGetFastRouteRouterRouter()
{
$router = $this->getRouter();
$this->assertSame($this->fastRouter->reveal(), $router->getRouter());
}

public function testWillLazyInstantiateAFastRouteCollectorIfNoneIsProvidedToConstructor()
{
$router = new FastRouteRouter();
Expand Down
6 changes: 6 additions & 0 deletions test/Router/Zf2RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public function getRouter()
return new Zf2Router($this->zf2Router->reveal());
}

public function testGetZf2RouterRouter()
{
$router = $this->getRouter();
$this->assertSame($this->zf2Router->reveal(), $router->getRouter());
}

public function testWillLazyInstantiateAZf2TreeRouteStackIfNoneIsProvidedToConstructor()
{
$router = new Zf2Router();
Expand Down