ConfigurationTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Bundle\ClientBundle\Tests\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Processor;
15
use Xabbuh\XApi\Bundle\ClientBundle\DependencyInjection\Configuration;
16
17
/**
18
 * @author Christian Flothmann <[email protected]>
19
 */
20
class ConfigurationTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * @var Configuration
24
     */
25
    private $configuration;
26
27
    /**
28
     * @var Processor
29
     */
30
    private $processor;
31
32
    protected function setUp()
33
    {
34
        $this->configuration = new Configuration();
35
        $this->processor = new Processor();
36
    }
37
38
    /**
39
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
40
     */
41
    public function testBaseUrlRequired()
42
    {
43
        $this->processConfiguration(array(
44
            'clients' => array(
45
                'foo' => array(),
46
            ),
47
        ));
48
    }
49
50 View Code Duplication
    public function testDefaultVersion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $config = $this->processConfiguration(array(
53
            'clients' => array(
54
                'foo' => array(
55
                    'base_url' => 'http://example.com/xapi',
56
                ),
57
            ),
58
        ));
59
60
        $this->assertEquals('1.0.1', $config['clients']['foo']['version']);
61
    }
62
63
    /**
64
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
65
     */
66
    public function testInvalidVersion()
67
    {
68
        $this->processConfiguration(array(
69
            'clients' => array(
70
                'foo' => array(
71
                    'base_url' => 'http://example.com/xapi',
72
                    'version' => '2.0',
73
                ),
74
            ),
75
        ));
76
    }
77
78
    /**
79
     * @dataProvider validVersions
80
     */
81 View Code Duplication
    public function testValidVersion($version)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
    {
83
        $config = $this->processConfiguration(array(
84
            'clients' => array(
85
                'foo' => array(
86
                    'base_url' => 'http://example.com/xapi',
87
                    'version' => $version,
88
                ),
89
            ),
90
        ));
91
92
        $this->assertEquals($version, $config['clients']['foo']['version']);
93
    }
94
95
    private function processConfiguration(array $config)
96
    {
97
        return $this->processor->processConfiguration($this->configuration, array($config));
98
    }
99
100
    public function validVersions()
101
    {
102
        return array(array('1.0.0'), array('1.0.1'));
103
    }
104
}
105