Completed
Pull Request — master (#4)
by Pavel
10:02
created

ConfigurationTest::testEntityCacheConfigParsing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 68
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 42
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 68
ccs 42
cts 42
cp 1
rs 9.2447
c 1
b 0
f 0
cc 1
eloc 35
nc 1
nop 0
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Bankiru\Api\Tests;
4
5
use Bankiru\Api\DependencyInjection\BankiruDoctrineApiExtension;
6
use Bankiru\Api\DependencyInjection\Configuration;
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Component\Config\Definition\Processor;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
final class ConfigurationTest extends TestCase
12
{
13 1
    public function testEntityCacheConfigParsing()
14
    {
15 1
        $configuration = new Configuration();
16 1
        $processor     = new Processor();
17
        $rawConfigs    = [
18
            [
19 1
                'entity_cache'   => null,
20 1
            ],
21
            [
22 1
                'entity_cache'   => 'test_cache',
23
24 1
            ],
25
            [
26
                'entity_cache'   => [
27 1
                    'logger' => 'logger',
28 1
                ],
29 1
            ],
30
            [
31
                'entity_cache'   =>
32
                    [
33
                        'configuration' => [
34
                            'TestEntity' => [
35 1
                                'ttl'   => 10,
36
                                'extra' => [
37 1
                                    'quick_search' => false,
38 1
                                ],
39 1
                            ],
40 1
                        ],
41 1
                    ],
42 1
            ],
43
            [
44
                'entity_cache'   =>
45
                    [
46
                        'configuration' => [
47 1
                            'TestEntity' => 900,
48 1
                        ],
49 1
                    ],
50 1
            ],
51
            [
52
                'entity_cache'   =>
53
                    [
54
                        'configuration' => [
55
                            'TestEntity' => [
56 1
                                'enabled' => false,
57
                                'extra'   => [
58 1
                                    'quick_search' => true,
59 1
                                ],
60 1
                            ],
61 1
                        ],
62 1
                    ],
63 1
            ],
64 1
        ];
65 1
        $configs       = $processor->processConfiguration(
66 1
            $configuration,
67
            $rawConfigs
68 1
        );
69
70 1
        self::assertTrue($configs['entity_cache']['enabled']);
71 1
        self::assertEquals('test_cache', $configs['entity_cache']['service']);
72 1
        self::assertFalse($configs['entity_cache']['configuration']['TestEntity']['enabled']);
73 1
        self::assertEquals(900, $configs['entity_cache']['configuration']['TestEntity']['ttl']);
74 1
        self::assertTrue($configs['entity_cache']['configuration']['TestEntity']['extra']['quick_search']);
75 1
        self::assertEquals('logger', $configs['entity_cache']['logger']);
76
77 1
        $builder   = new ContainerBuilder();
78 1
        $extension = new BankiruDoctrineApiExtension();
79 1
        $extension->load($rawConfigs, $builder);
80 1
    }
81
}
82