Skip to content

Commit

Permalink
Added getBasePath method to Router
Browse files Browse the repository at this point in the history
* Added docblock for new method
* Added tests for new method
  • Loading branch information
chantron committed Oct 11, 2018
1 parent 6d34747 commit 0b3209b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Slim/Router.php
Expand Up @@ -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.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/RouterTest.php
Expand Up @@ -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('');
Expand Down

0 comments on commit 0b3209b

Please sign in to comment.