From 0b3209b02874f3e5cb884c14d1889167fb0bee75 Mon Sep 17 00:00:00 2001 From: Chandler Blum Date: Thu, 11 Oct 2018 16:58:31 -0400 Subject: [PATCH] Added getBasePath method to Router * Added docblock for new method * Added tests for new method --- Slim/Router.php | 10 ++++++++++ tests/RouterTest.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/Slim/Router.php b/Slim/Router.php index 83116288c..0c3ebe41e 100644 --- a/Slim/Router.php +++ b/Slim/Router.php @@ -111,6 +111,16 @@ public function setBasePath($basePath) return $this; } + /** + * Get the base path used in pathFor() + * + * @return string + */ + public function getBasePath() + { + return $this->basePath; + } + /** * Set path to fast route cache file. If this is false then route caching is disabled. * diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 228e36bcf..84d2b8424 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -86,6 +86,13 @@ public function testRelativePathFor() ); } + public function testGetBasePath() + { + $this->router->setBasePath('/new/base/path'); + $this->assertFalse(('/not/the/new/base/path' === $this->router->getBasePath())); + $this->assertEquals('/new/base/path', $this->router->getBasePath()); + } + public function testPathForWithNoBasePath() { $this->router->setBasePath('');