From 26f8624681a1112dcc5be5556eca988d4f04abdc Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 17 Sep 2015 02:45:18 +0700 Subject: [PATCH 1/2] add getRouter() in Routers --- src/Router/AuraRouter.php | 8 ++++++++ src/Router/FastRouteRouter.php | 8 ++++++++ src/Router/Zf2Router.php | 8 ++++++++ test/Router/AuraRouterTest.php | 6 ++++++ test/Router/FastRouteRouterTest.php | 6 ++++++ test/Router/Zf2RouterTest.php | 6 ++++++ 6 files changed, 42 insertions(+) diff --git a/src/Router/AuraRouter.php b/src/Router/AuraRouter.php index 747d8049..789cfb12 100644 --- a/src/Router/AuraRouter.php +++ b/src/Router/AuraRouter.php @@ -66,6 +66,14 @@ private function createRouter() ); } + /** + * @return Router + */ + public function getRouter() + { + return $this->router; + } + /** * Add a route to the underlying router. * diff --git a/src/Router/FastRouteRouter.php b/src/Router/FastRouteRouter.php index c65ef865..4ad6385e 100644 --- a/src/Router/FastRouteRouter.php +++ b/src/Router/FastRouteRouter.php @@ -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. * diff --git a/src/Router/Zf2Router.php b/src/Router/Zf2Router.php index bd03536a..f5fb8d0d 100644 --- a/src/Router/Zf2Router.php +++ b/src/Router/Zf2Router.php @@ -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. * diff --git a/test/Router/AuraRouterTest.php b/test/Router/AuraRouterTest.php index f16be734..9d874c1e 100644 --- a/test/Router/AuraRouterTest.php +++ b/test/Router/AuraRouterTest.php @@ -26,6 +26,12 @@ public function getRouter() return new AuraRouter($this->auraRouter->reveal()); } + public function testGetAuraRouter() + { + $router = $this->getRouter(); + $this->assertSame($this->auraRouter->reveal(), $router->getRouter()); + } + public function testAddingRouteProxiesToAuraRouter() { $route = new Route('/foo', 'foo', ['GET']); diff --git a/test/Router/FastRouteRouterTest.php b/test/Router/FastRouteRouterTest.php index f68a2fc4..73b421c4 100644 --- a/test/Router/FastRouteRouterTest.php +++ b/test/Router/FastRouteRouterTest.php @@ -33,6 +33,12 @@ public function getRouter() ); } + public function testGetAuraRouter() + { + $router = $this->getRouter(); + $this->assertSame($this->fastRouter->reveal(), $router->getRouter()); + } + public function testWillLazyInstantiateAFastRouteCollectorIfNoneIsProvidedToConstructor() { $router = new FastRouteRouter(); diff --git a/test/Router/Zf2RouterTest.php b/test/Router/Zf2RouterTest.php index f00648c2..4783bedf 100644 --- a/test/Router/Zf2RouterTest.php +++ b/test/Router/Zf2RouterTest.php @@ -27,6 +27,12 @@ public function getRouter() return new Zf2Router($this->zf2Router->reveal()); } + public function testGetAuraRouter() + { + $router = $this->getRouter(); + $this->assertSame($this->zf2Router->reveal(), $router->getRouter()); + } + public function testWillLazyInstantiateAZf2TreeRouteStackIfNoneIsProvidedToConstructor() { $router = new Zf2Router(); From d797fde6968092715d3b322abae51d3f844b9026 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 17 Sep 2015 02:55:28 +0700 Subject: [PATCH 2/2] update router test naming --- test/Router/AuraRouterTest.php | 2 +- test/Router/FastRouteRouterTest.php | 2 +- test/Router/Zf2RouterTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Router/AuraRouterTest.php b/test/Router/AuraRouterTest.php index 9d874c1e..a887bda4 100644 --- a/test/Router/AuraRouterTest.php +++ b/test/Router/AuraRouterTest.php @@ -26,7 +26,7 @@ public function getRouter() return new AuraRouter($this->auraRouter->reveal()); } - public function testGetAuraRouter() + public function testGetAuraRouterRouter() { $router = $this->getRouter(); $this->assertSame($this->auraRouter->reveal(), $router->getRouter()); diff --git a/test/Router/FastRouteRouterTest.php b/test/Router/FastRouteRouterTest.php index 73b421c4..c73f5be4 100644 --- a/test/Router/FastRouteRouterTest.php +++ b/test/Router/FastRouteRouterTest.php @@ -33,7 +33,7 @@ public function getRouter() ); } - public function testGetAuraRouter() + public function testGetFastRouteRouterRouter() { $router = $this->getRouter(); $this->assertSame($this->fastRouter->reveal(), $router->getRouter()); diff --git a/test/Router/Zf2RouterTest.php b/test/Router/Zf2RouterTest.php index 4783bedf..0954b303 100644 --- a/test/Router/Zf2RouterTest.php +++ b/test/Router/Zf2RouterTest.php @@ -27,7 +27,7 @@ public function getRouter() return new Zf2Router($this->zf2Router->reveal()); } - public function testGetAuraRouter() + public function testGetZf2RouterRouter() { $router = $this->getRouter(); $this->assertSame($this->zf2Router->reveal(), $router->getRouter());