ConfigurationTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 51
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

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