Skip to content

Commit

Permalink
Merge 469f25e into 80a52f7
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-cz committed Oct 4, 2019
2 parents 80a52f7 + 469f25e commit 06bf63f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Slim/Routing/RouteParser.php
Expand Up @@ -125,4 +125,14 @@ public function fullUrlFor(UriInterface $uri, string $routeName, array $data = [
$protocol = ($scheme ? $scheme . ':' : '') . ($authority ? '//' . $authority : '');
return $protocol . $path;
}

/**
* Get base path
*
* @return string
*/
public function getBasePath(): string
{
return $this->routeCollector->getBasePath();
}
}
13 changes: 13 additions & 0 deletions tests/Routing/RouteParserTest.php
Expand Up @@ -194,4 +194,17 @@ public function testFullUrlFor()
$expectedResult = 'http://example.com:8080/app/123';
$this->assertEquals($expectedResult, $result);
}

public function testGetBasePath()
{
$responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);
$callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);

$routeCollector = new RouteCollector($responseFactoryProphecy->reveal(), $callableResolverProphecy->reveal());
$routeCollector->setBasePath('/app');

$routeParser = $routeCollector->getRouteParser();

$this->assertEquals('/app', $routeParser->getBasePath());
}
}

0 comments on commit 06bf63f

Please sign in to comment.