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

DeleteTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 33
dl 0
loc 51
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPatch() 0 40 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
use Spiral\Config\Patch\Delete;
16
17
class DeleteTest extends BaseTest
18
{
19
    public function testPatch(): void
20
    {
21
        $cf = $this->getFactory();
22
23
        $this->assertEquals(['value' => 'value!'], $cf->getConfig('scope'));
24
25
        $cf->modify('scope', new Append('.', 'other', ['a' => 'b']));
26
        $cf->modify('scope', new Delete('.', 'value'));
27
28
        $this->assertSame([
29
            'other' => ['a' => 'b']
30
        ], $cf->getConfig('scope'));
31
32
        $cf->modify('scope', new Append('.', null, 'c'));
33
34
        $this->assertSame([
35
            'other' => ['a' => 'b'],
36
            'c'
37
        ], $cf->getConfig('scope'));
38
39
        $cf->modify('scope', new Delete('.', null, 'c'));
40
41
        $this->assertSame([
42
            'other' => ['a' => 'b']
43
        ], $cf->getConfig('scope'));
44
45
        $cf->modify('scope', new Delete('other', 'a'));
46
        $this->assertSame([
47
            'other' => []
48
        ], $cf->getConfig('scope'));
49
50
        $cf->modify('scope', new Append('.', 'other', ['a' => 'b']));
51
        $this->assertSame([
52
            'other' => ['a' => 'b']
53
        ], $cf->getConfig('scope'));
54
55
        $cf->modify('scope', new Delete('other', null, 'b'));
56
        $this->assertSame([
57
            'other' => []
58
        ], $cf->getConfig('scope'));
59
    }
60
61
    public function testException(): void
62
    {
63
        $cf = $this->getFactory();
64
        $this->assertEquals(['value' => 'value!'], $cf->getConfig('scope'));
65
66
        $cf->modify('scope', new Delete('something.', 'other'));
67
        $this->assertEquals(['value' => 'value!'], $cf->getConfig('scope'));
68
    }
69
}
70