Passed
Pull Request — master (#6)
by
unknown
02:45
created

ConfigurationTest::testEmptyConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 20
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace ElevenLabs\ApiServiceBundle\Tests\DependencyInjection;
4
5
use ElevenLabs\ApiServiceBundle\DependencyInjection\Configuration;
6
use ElevenLabs\ApiServiceBundle\DependencyInjection\ApiServiceExtension;
7
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase;
8
9
class ConfigurationTest extends AbstractExtensionConfigurationTestCase
10
{
11
12
    protected function getContainerExtension()
13
    {
14
        return new ApiServiceExtension();
15
    }
16
17
    protected function getConfiguration()
18
    {
19
        return new Configuration(true);
20
    }
21
22
    public function testEmptyConfiguration()
23
    {
24
        $expectedEmptyConfig = [
25
            'default_services' => [
26
                'client' => 'httplug.client',
27
                'message_factory' => 'httplug.message_factory',
28
                'uri_factory' => 'httplug.uri_factory',
29
            ],
30
            'cache' => [
31
                'enabled' => false
32
            ],
33
            'pagination' => [],
34
            'apis' => [],
35
        ];
36
37
        $fixturesPath =  __DIR__.'/../Resources/Fixtures';
38
39
        $this->assertProcessedConfigurationEquals(
40
            $expectedEmptyConfig,
41
            [$fixturesPath.'/config/empty.yml']
42
        );
43
    }
44
45
    public function testSupportsAllConfigFormats()
46
    {
47
        $expectedConfiguration = [
48
            'default_services' => [
49
                'client' => 'httplug.client.acme',
50
                'uri_factory' => 'my.uri_factory',
51
                'message_factory' => 'my.message_factory',
52
            ],
53
            'cache' => [
54
                'enabled' => true,
55
                'service' => 'my.psr6_cache_impl'
56
            ],
57
            'pagination' => [
58
                'header' => [
59
                    'page' => 'X-Page',
60
                    'perPage' => 'X-Per-Page',
61
                    'totalPages' => 'X-Total-Pages',
62
                    'totalItems' => 'X-Total-Items',
63
                ]
64
            ],
65
            'apis' => [
66
                'foo' => [
67
                    'schema' => '/path/to/foo.yml',
68
                    'client' => 'api_service.client',
69
                    'config' => [
70
                        'baseUri' => null,
71
                        'validateRequest' => true,
72
                        'validateResponse' => false,
73
                        'returnResponse' => false
74
                    ]
75
                ],
76
                'bar' => [
77
                    'schema' => '/path/to/bar.json',
78
                    'client' => 'httplug.client.bar',
79
                    'config' => [
80
                        'baseUri' => 'https://bar.com',
81
                        'validateRequest' => false,
82
                        'validateResponse' => true,
83
                        'returnResponse' => true
84
                    ]
85
                ]
86
            ],
87
        ];
88
89
        $fixturesPath =  __DIR__.'/../Resources/Fixtures';
90
91
        $this->assertProcessedConfigurationEquals(
92
            $expectedConfiguration,
93
            [$fixturesPath.'/config/full.yml']
94
        );
95
    }
96
}
97