Passed
Push — master ( abee1f...edc958 )
by Kirill
03:08
created

AppendTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPatch() 0 22 1
A testException() 0 7 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Config;
13
14
use Spiral\Config\Patch\Append;
15
16
class AppendTest extends BaseTest
17
{
18
    public function testPatch(): void
19
    {
20
        $cf = $this->getFactory();
21
22
        $this->assertEquals(['value' => 'value!'], $cf->getConfig('scope'));
23
24
        $cf->modify('scope', new Append('.', 'other', ['a' => 'b']));
25
26
        $this->assertSame([
27
            'value' => 'value!',
28
            'other' => ['a' => 'b']
29
        ], $cf->getConfig('scope'));
30
31
        $cf->modify('scope', new Append('other.', null, 'c'));
32
33
        $this->assertSame([
34
            'value' => 'value!',
35
            'other' => [
36
                'a' => 'b',
37
                'c'
38
            ]
39
        ], $cf->getConfig('scope'));
40
    }
41
42
    /**
43
     * @expectedException \Spiral\Config\Exception\PatchException
44
     */
45
    public function testException(): void
46
    {
47
        $cf = $this->getFactory();
48
        $config = $cf->getConfig('scope');
49
        $this->assertEquals(['value' => 'value!'], $config);
50
51
        $cf->modify('scope', new Append('other', 'other', ['a' => 'b']));
52
    }
53
}
54