mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-01 06:37:04 +03:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink\Rest;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Shlinkio\Shlink\Rest\ConfigProvider;
|
|
|
|
class ConfigProviderTest extends TestCase
|
|
{
|
|
private ConfigProvider $configProvider;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$this->configProvider = new ConfigProvider();
|
|
}
|
|
|
|
/** @test */
|
|
public function properConfigIsReturned(): void
|
|
{
|
|
$config = ($this->configProvider)();
|
|
|
|
$this->assertArrayHasKey('routes', $config);
|
|
$this->assertArrayHasKey('dependencies', $config);
|
|
}
|
|
|
|
/** @test */
|
|
public function routesAreProperlyPrefixed(): void
|
|
{
|
|
$configProvider = new ConfigProvider(fn () => [
|
|
'routes' => [
|
|
['path' => '/foo'],
|
|
['path' => '/bar'],
|
|
['path' => '/baz/foo'],
|
|
['path' => '/health'],
|
|
],
|
|
]);
|
|
|
|
$config = $configProvider();
|
|
|
|
$this->assertEquals([
|
|
['path' => '/rest/v{version:1|2}/foo'],
|
|
['path' => '/rest/v{version:1|2}/bar'],
|
|
['path' => '/rest/v{version:1|2}/baz/foo'],
|
|
['path' => '/rest/health'],
|
|
], $config['routes']);
|
|
}
|
|
}
|