CollectionSpec::it_is_iterable()   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\Collection;
9
use PhpSpec\ObjectBehavior;
10
11
final class CollectionSpec extends ObjectBehavior
12
{
13
    function let(Dictionary $dictionary, Dictionary $dictionary2)
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($dictionary, $dictionary2);
16
        $dictionary->getName()->willReturn('foo');
17
        $dictionary2->getName()->willReturn('dictionary');
18
    }
19
20
    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...
21
    {
22
        $this->shouldHaveType(Collection::class);
23
    }
24
25
    function it_is_an_array_access()
26
    {
27
        $this->shouldHaveType(\ArrayAccess::class);
28
    }
29
30
    function it_is_iterable()
31
    {
32
        $this->shouldHaveType(\IteratorAggregate::class);
33
    }
34
35
    function it_is_countable()
36
    {
37
        $this->shouldHaveType(\Countable::class);
38
    }
39
40
    function it_should_entry_if_it_exists()
41
    {
42
        $this->shouldHaveKey('foo');
43
        $this->shouldNotHaveKey('baz');
44
    }
45
46
    function it_counts_entries()
47
    {
48
        $this->count()->shouldReturn(2);
0 ignored issues
show
Bug introduced by
The method count() does not exist on spec\Knp\DictionaryBundl...ctionary\CollectionSpec. 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

48
        $this->/** @scrutinizer ignore-call */ 
49
               count()->shouldReturn(2);
Loading history...
49
    }
50
51
    function it_is_a_list_ob_dictionaries($dictionary, $dictionary2)
52
    {
53
        $this->getIterator()->getArrayCopy()->shouldReturn([
0 ignored issues
show
Bug introduced by
The method getIterator() does not exist on spec\Knp\DictionaryBundl...ctionary\CollectionSpec. 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

53
        $this->/** @scrutinizer ignore-call */ 
54
               getIterator()->getArrayCopy()->shouldReturn([
Loading history...
54
            'foo'        => $dictionary,
55
            'dictionary' => $dictionary2,
56
        ]);
57
    }
58
59
    function its_offsetSet_method_cannot_be_called()
60
    {
61
        $this->shouldThrow(\RuntimeException::class)->duringOffsetSet('foo', 'bar');
62
    }
63
64
    function its_offsetUnset_method_cannot_be_called()
65
    {
66
        $this->shouldThrow(\RuntimeException::class)->duringOffsetUnset('foo');
67
    }
68
}
69