Completed
Pull Request — master (#5)
by GBProd
03:43
created

ConfigurationTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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