GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ConfigurationTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 48
dl 0
loc 72
c 0
b 0
f 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConfiguration() 0 26 1
A testAddParamsToNotArray() 0 7 1
A testAddParams() 0 33 1
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Host;
9
10
use Deployer\Configuration;
11
use Deployer\Exception\ConfigurationException;
12
use PHPUnit\Framework\TestCase;
13
14
class ConfigurationTest extends TestCase
15
{
16
    public function testConfiguration()
17
    {
18
        $config = new Configuration();
19
        $config->set('int', 42);
20
        $config->set('string', 'value');
21
        $config->set('array', [1, 'two']);
22
        $config->set('hyphen-ated', 'hyphen');
23
        $config->set('parse', 'is {{int}}');
24
        $config->set('parse-hyphen', 'has {{hyphen-ated}}');
25
        $config->set('callback', function () {
26
            return 'callback';
27
        });
28
        $this->assertEquals(42, $config->get('int'));
29
        $this->assertEquals('value', $config->get('string'));
30
        $this->assertEquals([1, 'two'], $config->get('array'));
31
        $this->assertEquals('default', $config->get('no', 'default'));
32
        $this->assertEquals(null, $config->get('no', null));
33
        $this->assertEquals('callback', $config->get('callback'));
34
        $this->assertEquals('is 42', $config->get('parse'));
35
        $this->assertEquals('has hyphen', $config->get('parse-hyphen'));
36
37
        $config->set('int', 11);
38
        $this->assertEquals('is 11', $config->get('parse'));
39
40
        $this->expectException('RuntimeException');
41
        $config->get('so');
42
    }
43
44
    public function testAddParams()
45
    {
46
        $config = new Configuration();
47
        $config->set('config', [
48
            'one',
49
            'two' => 2,
50
            'nested' => [],
51
        ]);
52
        $config->add('config', [
53
            'two' => 20,
54
            'nested' => [
55
                'first',
56
            ],
57
        ]);
58
        $config->add('config', [
59
            'nested' => [
60
                'second',
61
            ],
62
        ]);
63
        $config->add('config', [
64
            'extra',
65
        ]);
66
67
        $expected = [
68
            'one',
69
            'two' => 20,
70
            'nested' => [
71
                'first',
72
                'second',
73
            ],
74
            'extra',
75
        ];
76
        $this->assertEquals($expected, $config->get('config'));
77
    }
78
79
    public function testAddParamsToNotArray()
80
    {
81
        $this->expectException(ConfigurationException::class);
82
83
        $config = new Configuration();
84
        $config->set('config', 'option');
85
        $config->add('config', ['three']);
86
    }
87
}
88