Added feature flag to enable/disable multi-segment support

This commit is contained in:
Alejandro Celaya
2022-08-04 11:49:33 +02:00
parent 7acf27dd38
commit 619999d4f8
9 changed files with 38 additions and 14 deletions

View File

@@ -33,9 +33,9 @@ class ConfigProviderTest extends TestCase
* @test
* @dataProvider provideRoutesConfig
*/
public function routesAreProperlyPrefixed(array $routes, array $expected): void
public function routesAreProperlyPrefixed(array $routes, bool $multiSegmentEnabled, array $expected): void
{
self::assertEquals($expected, ConfigProvider::applyRoutesPrefix($routes));
self::assertEquals($expected, ConfigProvider::applyRoutesPrefix($routes, $multiSegmentEnabled));
}
public function provideRoutesConfig(): iterable
@@ -47,6 +47,7 @@ class ConfigProviderTest extends TestCase
['path' => '/baz/foo'],
['path' => '/health'],
],
false,
[
['path' => '/rest/v{version:1|2}/foo'],
['path' => '/rest/v{version:1|2}/bar'],
@@ -61,11 +62,25 @@ class ConfigProviderTest extends TestCase
['path' => '/bar'],
['path' => '/baz/foo'],
],
false,
[
['path' => '/rest/v{version:1|2}/foo'],
['path' => '/rest/v{version:1|2}/bar'],
['path' => '/rest/v{version:1|2}/baz/foo'],
],
];
yield 'multi-segment enabled' => [
[
['path' => '/foo'],
['path' => '/bar/{shortCode}'],
['path' => '/baz/{shortCode}/foo'],
],
true,
[
['path' => '/rest/v{version:1|2}/foo'],
['path' => '/rest/v{version:1|2}/bar/{shortCode:.+}'],
['path' => '/rest/v{version:1|2}/baz/{shortCode:.+}/foo'],
],
];
}
}