ConfigurationTest::testEmptyConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Tests\GBProd\ElasticaSpecificationBundle\DependencyInjection;
4
5
use GBProd\ElasticaSpecificationBundle\DependencyInjection\Configuration;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
8
use Symfony\Component\Config\Definition\Processor;
9
10
/**
11
 * Tests for Configuration
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class ConfigurationTest extends TestCase
16
{
17
    private $configuration;
18
19
    public function setUp()
20
    {
21
        $this->configuration = new Configuration();
22
    }
23
24
    public function testEmptyConfiguration()
25
    {
26
        $processed = $this->process([]);
27
28
        $this->assertEquals([
29
            'dsl_version' => 'Latest'
30
        ], $processed);
31
    }
32
33
    protected function process(array $config)
34
    {
35
        $processor = new Processor();
36
37
        return $processor->processConfiguration(
38
            $this->configuration,
39
            $config
40
        );
41
    }
42
43
    public function testSetAValidBuilderVersion()
44
    {
45
        $processed = $this->process([
46
            [
47
                'dsl_version' => 'Version240',
48
            ]
49
        ]);
50
51
        $this->assertEquals([
52
            'dsl_version' => 'Version240'
53
        ], $processed);
54
    }
55
56
    public function testSetAnInvalidBuilderVersion()
57
    {
58
        $this->expectException(\InvalidArgumentException::class);
59
60
        $this->process([
61
            [
62
                'dsl_version' => 'Fake',
63
            ]
64
        ]);
65
    }
66
}
67