ConfigurationTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidStoreValue() 0 11 1
A testMultipleStoreConfiguration() 0 19 1
1
<?php
2
3
/*
4
 * This file is part of the distributed-configuration-bundle package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Maikuro\DistributedConfigurationBundle\Tests;
17
18
use Maikuro\DistributedConfigurationBundle\DependencyInjection\Configuration;
19
use Symfony\Component\Config\Definition\Processor;
20
21
class ConfigurationTest extends \PHPUnit_Framework_TestCase
22
{
23
    public function testInvalidStoreValue()
24
    {
25
        $configs = ['gundan_distributed_configuration' => ['store' => ['type' => 'wrong_store']]];
26
27
        $processor = new Processor();
28
        $configuration = new Configuration();
29
30
        $this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
31
32
        $config = $processor->processConfiguration($configuration, $configs);
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
33
    }
34
35
    public function testMultipleStoreConfiguration()
36
    {
37
        $configs =
38
        [
39
            'gundan_distributed_configuration' => [
40
                'store' => [
41
                    'predis' => ['client_id' => 'redis.client_id', 'scheme' => 'http'],
42
                ],
43
            ],
44
        ];
45
46
        $processor = new Processor();
47
        $configuration = new Configuration();
48
49
        $config = $processor->processConfiguration($configuration, $configs);
50
51
        $this->assertEquals($config['store']['type'], 'predis');
52
        $this->assertEquals($config['store']['predis']['client_id'], 'redis.client_id');
53
    }
54
}
55