Completed
Push — develop ( a14d83...6bfc05 )
by Mathieu
01:47
created

ContainerTest::testContainerWarehouse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
class ContainerTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
3
{
4
    public function testContainerExists()
5
    {
6
        $testContainer = new \Suricate\Container([
7
            'a' => 1,
8
            'b' => 3,
9
            5 => 'z'
10
        ]);
11
        
12
        
13
        $this->assertTrue($testContainer->offsetExists('a'));
14
        $this->assertTrue($testContainer->offsetExists(5));
15
        $this->assertFalse($testContainer->offsetExists('c'));
16
        $this->assertFalse($testContainer->offsetExists(6));
17
18
        $this->assertTrue(isset($testContainer['a']));
19
        $this->assertTrue(isset($testContainer[5]));
20
        $this->assertFalse(isset($testContainer[99]));
21
    }
22
23
    public function testContainerGet()
24
    {
25
        $testContainer = new \Suricate\Container([
26
            'a' => 1,
27
            'b' => 3,
28
            5 => 'z'
29
        ]);        
30
        
31
        $this->assertEquals($testContainer['a'], 1);
32
        $this->assertEquals($testContainer[5], 'z');
33
34
        $this->expectException(\InvalidArgumentException::class);
35
        $tmp = $testContainer['zz'];
0 ignored issues
show
Unused Code introduced by
The assignment to $tmp is dead and can be removed.
Loading history...
36
    }
37
38
    public function testContainerSet()
39
    {
40
        $payload = [
41
            'a' => 1,
42
            'b' => 3,
43
            5 => 'z'
44
        ];
45
46
        $warehouse = ['zz' => 'my_value'];
47
        
48
        $testContainer = new \Suricate\Container($payload);
49
        $this->assertAttributeEquals([], 'warehouse', $testContainer);
50
        $this->assertAttributeEquals($payload, 'content', $testContainer);
51
52
        $testContainer->setWarehouse($warehouse);
53
        $this->assertAttributeEquals($warehouse, 'warehouse', $testContainer);
54
55
56
    }
57
58
    public function testContainerUnset()
59
    {
60
        $payload = [
61
            'a' => 1,
62
            'b' => 3,
63
            5 => 'z'
64
        ];
65
66
        $testContainer = new \Suricate\Container($payload);
67
        $this->assertAttributeEquals($payload, 'content', $testContainer);
68
        unset($testContainer['b']);
69
        $this->assertAttributeEquals( [
70
            'a' => 1,
71
            5 => 'z'
72
        ], 'content', $testContainer);
73
    }
74
75
    public function testContainerWarehouse()
76
    {
77
        $warehouse = ['test' => 'stdClass'];
78
79
        $testContainer = new \Suricate\Container([]);
80
        $testContainer->setWarehouse($warehouse);
81
        $this->assertEquals($testContainer['test'], new \stdClass);
82
    }
83
}
84