CombinedSpec::it_is_initializable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Knp\DictionaryBundle\Dictionary;
6
7
use Knp\DictionaryBundle\Dictionary;
8
use Knp\DictionaryBundle\Dictionary\Combined;
9
use PhpSpec\ObjectBehavior;
10
11
final class CombinedSpec extends ObjectBehavior
12
{
13
    function let(Dictionary $dictionary1, Dictionary $dictionary2, Dictionary $dictionary3)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
14
    {
15
        $this->beConstructedWith(
16
            'combined_dictionary',
17
            $dictionary1,
18
            $dictionary2,
19
            $dictionary3
20
        );
21
    }
22
23
    function it_is_initializable()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
24
    {
25
        $this->shouldHaveType(Combined::class);
26
    }
27
28
    function it_is_a_dictionary()
29
    {
30
        $this->shouldImplement(Dictionary::class);
31
    }
32
33
    function it_access_to_value_like_an_array($dictionary1, $dictionary2, $dictionary3)
34
    {
35
        $dictionary1->getIterator()->willReturn(new \ArrayIterator(['foo1' => 'foo10']));
36
37
        $dictionary2->getIterator()->willReturn(new \ArrayIterator(['bar1' => 'bar10']));
38
39
        $dictionary3->getIterator()->willReturn(new \ArrayIterator(['baz1' => 'baz10']));
40
41
        $this['foo1']->shouldBe('foo10');
42
        $this['bar1']->shouldBe('bar10');
43
        $this['baz1']->shouldBe('baz10');
44
    }
45
46
    function it_getvalues_should_return_dictionaries_values($dictionary1, $dictionary2, $dictionary3)
47
    {
48
        $dictionary1->getIterator()->willReturn(new \ArrayIterator([
49
            'foo1' => 'foo10',
50
            'foo2' => 'foo20',
51
        ]));
52
53
        $dictionary2->getIterator()->willReturn(new \ArrayIterator([
54
            'bar1' => 'bar10',
55
            'bar2' => 'bar20',
56
        ]));
57
58
        $dictionary3->getIterator()->willReturn(new \ArrayIterator([
59
            'foo1' => 'baz10',
60
            'bar2' => 'baz20',
61
        ]));
62
63
        $this->getKeys()->shouldReturn([
0 ignored issues
show
Bug introduced by
The method getKeys() does not exist on spec\Knp\DictionaryBundle\Dictionary\CombinedSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
        $this->/** @scrutinizer ignore-call */ 
64
               getKeys()->shouldReturn([
Loading history...
64
            'foo1',
65
            'foo2',
66
            'bar1',
67
            'bar2',
68
        ]);
69
        $this->getValues()->shouldReturn([
0 ignored issues
show
Bug introduced by
The method getValues() does not exist on spec\Knp\DictionaryBundle\Dictionary\CombinedSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
        $this->/** @scrutinizer ignore-call */ 
70
               getValues()->shouldReturn([
Loading history...
70
            'foo1' => 'baz10',
71
            'foo2' => 'foo20',
72
            'bar1' => 'bar10',
73
            'bar2' => 'baz20',
74
        ]);
75
    }
76
77
    function it_can_iterate_over_dictionaries($dictionary1, $dictionary2, $dictionary3)
78
    {
79
        $dictionary1->getIterator()->willReturn(new \ArrayIterator([
80
            'foo1' => 'foo10',
81
            'foo2' => 'foo20',
82
        ]));
83
84
        $dictionary2->getIterator()->willReturn(new \ArrayIterator([
85
            'bar1' => 'bar10',
86
            'bar2' => 'bar20',
87
        ]));
88
89
        $dictionary3->getIterator()->willReturn(new \ArrayIterator([
90
            'foo2' => 'baz20',
91
            'bar2' => 'baz20',
92
        ]));
93
94
        $this->shouldIterateLike([
95
            'foo1' => 'foo10',
96
            'foo2' => 'baz20',
97
            'bar1' => 'bar10',
98
            'bar2' => 'baz20',
99
        ]);
100
    }
101
102
    function it_sums_the_count_of_elements($dictionary1, $dictionary2, $dictionary3)
103
    {
104
        $dictionary1->getIterator()->willReturn(new \ArrayIterator([
105
            'foo1' => 'foo10',
106
        ]));
107
108
        $dictionary2->getIterator()->willReturn(new \ArrayIterator([
109
            'bar1' => 'bar10',
110
            'bar2' => 'bar20',
111
        ]));
112
113
        $dictionary3->getIterator()->willReturn(new \ArrayIterator([
114
            'baz1' => 'baz10',
115
            'baz2' => 'baz20',
116
            'baz3' => 'baz30',
117
            'baz4' => 'baz40',
118
        ]));
119
120
        $this->count()->shouldReturn(7);
0 ignored issues
show
Bug introduced by
The method count() does not exist on spec\Knp\DictionaryBundle\Dictionary\CombinedSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

120
        $this->/** @scrutinizer ignore-call */ 
121
               count()->shouldReturn(7);
Loading history...
121
    }
122
123
    function its_getname_should_return_dictionary_name()
124
    {
125
        $this->getName()->shouldReturn('combined_dictionary');
0 ignored issues
show
Bug introduced by
The method getName() does not exist on spec\Knp\DictionaryBundle\Dictionary\CombinedSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

125
        $this->/** @scrutinizer ignore-call */ 
126
               getName()->shouldReturn('combined_dictionary');
Loading history...
126
    }
127
}
128