Ensured base path is not prefixed more than it should

This commit is contained in:
Alejandro Celaya
2022-03-14 19:26:02 +01:00
parent 01bae358f9
commit 613bdd82b0
4 changed files with 4 additions and 37 deletions

View File

@@ -24,42 +24,16 @@ class BasePathPrefixerTest extends TestCase
array $originalConfig,
array $expectedRoutes,
array $expectedMiddlewares,
string $expectedHostname,
): void {
[
'routes' => $routes,
'middleware_pipeline' => $middlewares,
'url_shortener' => $urlShortener,
] = ($this->prefixer)($originalConfig);
['routes' => $routes, 'middleware_pipeline' => $middlewares] = ($this->prefixer)($originalConfig);
self::assertEquals($expectedRoutes, $routes);
self::assertEquals($expectedMiddlewares, $middlewares);
self::assertEquals([
'domain' => [
'hostname' => $expectedHostname,
],
], $urlShortener);
}
public function provideConfig(): iterable
{
$urlShortener = [
'domain' => [
'hostname' => null,
],
];
yield 'without anything' => [['url_shortener' => $urlShortener], [], [], ''];
yield 'with empty options' => [
[
'routes' => [],
'middleware_pipeline' => [],
'url_shortener' => $urlShortener,
],
[],
[],
'',
];
yield 'with empty options' => [['routes' => []], [], []];
yield 'with non-empty options' => [
[
'routes' => [
@@ -70,11 +44,6 @@ class BasePathPrefixerTest extends TestCase
['with' => 'no_path'],
['path' => '/rest', 'middleware' => []],
],
'url_shortener' => [
'domain' => [
'hostname' => 'doma.in',
],
],
'router' => ['base_path' => '/foo/bar'],
],
[
@@ -85,7 +54,6 @@ class BasePathPrefixerTest extends TestCase
['with' => 'no_path'],
['path' => '/foo/bar/rest', 'middleware' => []],
],
'doma.in/foo/bar',
];
}
}