Completed
Push — master ( 8cc4d3...038254 )
by Alejandro
16s queued 11s
created

ConfigProviderTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 39
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A routesAreProperlyPrefixed() 0 19 1
A properConfigIsReturned() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Rest;
6
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Rest\ConfigProvider;
9
10
class ConfigProviderTest extends TestCase
11
{
12
    /** @var ConfigProvider */
13
    private $configProvider;
14
15
    public function setUp(): void
16
    {
17
        $this->configProvider = new ConfigProvider();
18
    }
19
20
    /** @test */
21
    public function properConfigIsReturned(): void
22
    {
23
        $config = ($this->configProvider)();
24
25
        $this->assertArrayHasKey('routes', $config);
26
        $this->assertArrayHasKey('dependencies', $config);
27
    }
28
29
    /** @test */
30
    public function routesAreProperlyPrefixed(): void
31
    {
32
        $configProvider = new ConfigProvider(function () {
33
            return [
34
                'routes' => [
35
                    ['path' => '/foo'],
36
                    ['path' => '/bar'],
37
                    ['path' => '/baz/foo'],
38
                ],
39
            ];
40
        });
41
42
        $config = $configProvider();
43
44
        $this->assertEquals([
45
            ['path' => '/rest/v{version:1|2}/foo'],
46
            ['path' => '/rest/v{version:1|2}/bar'],
47
            ['path' => '/rest/v{version:1|2}/baz/foo'],
48
        ], $config['routes']);
49
    }
50
}
51