Passed
Push — master ( 414f0a...c0888e )
by Pierre
03:03
created

CombinedSpec::it_supports_specific_config()   A

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\Factory;
6
7
use ArrayIterator;
8
use Knp\DictionaryBundle\Dictionary;
9
use Knp\DictionaryBundle\Dictionary\Collection;
10
use Knp\DictionaryBundle\Dictionary\Factory;
11
use Knp\DictionaryBundle\Dictionary\Factory\Combined;
12
use PhpSpec\ObjectBehavior;
13
14
final class CombinedSpec extends ObjectBehavior
15
{
16
    function let()
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...
17
    {
18
        $this->beConstructedWith(new Collection());
19
    }
20
21
    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...
22
    {
23
        $this->shouldHaveType(Combined::class);
24
    }
25
26
    function it_is_a_factory()
27
    {
28
        $this->shouldHaveType(Factory::class);
29
    }
30
31
    function it_supports_specific_config()
32
    {
33
        $this->supports(['type' => 'combined'])->shouldReturn(true);
0 ignored issues
show
Bug introduced by
The method supports() does not exist on spec\Knp\DictionaryBundl...ry\Factory\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

33
        $this->/** @scrutinizer ignore-call */ 
34
               supports(['type' => 'combined'])->shouldReturn(true);
Loading history...
34
    }
35
36
    function it_creates_a_dictionary(Dictionary $dictionary1, Dictionary $dictionary2, Dictionary $dictionary3)
37
    {
38
        $dictionary1->getIterator()->willReturn(new ArrayIterator(['foo1' => 'foo10', 'foo2' => 'foo20']));
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Traversable. ( Ignorable by Annotation )

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

38
        $dictionary1->getIterator()->/** @scrutinizer ignore-call */ willReturn(new ArrayIterator(['foo1' => 'foo10', 'foo2' => 'foo20']));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
        $dictionary1->getName()->willReturn('dictionary1');
40
41
        $dictionary2->getIterator()->willReturn(new ArrayIterator(['bar1' => 'bar10', 'bar2' => 'bar20']));
42
        $dictionary2->getName()->willReturn('dictionary2');
43
44
        $dictionary3->getIterator()->willReturn(new ArrayIterator(['foo2' => 'baz20', 'bar2' => 'baz20']));
45
        $dictionary3->getName()->willReturn('dictionary3');
46
47
        $this->beConstructedWith(new Collection($dictionary1->getWrappedObject(), $dictionary2->getWrappedObject(), $dictionary3->getWrappedObject()));
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not exist on Knp\DictionaryBundle\Dictionary. ( Ignorable by Annotation )

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

47
        $this->beConstructedWith(new Collection($dictionary1->/** @scrutinizer ignore-call */ getWrappedObject(), $dictionary2->getWrappedObject(), $dictionary3->getWrappedObject()));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
49
        $config = [
50
            'type'         => 'combined',
51
            'dictionaries' => [
52
                'dictionary1',
53
                'dictionary2',
54
                'dictionary3',
55
            ],
56
        ];
57
58
        $dictionary = $this->create('combined_dictionary', $config);
0 ignored issues
show
Bug introduced by
The method create() does not exist on spec\Knp\DictionaryBundl...ry\Factory\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

58
        /** @scrutinizer ignore-call */ 
59
        $dictionary = $this->create('combined_dictionary', $config);
Loading history...
59
60
        $dictionary->getValues()->shouldReturn([
61
            'foo1' => 'foo10',
62
            'foo2' => 'baz20',
63
            'bar1' => 'bar10',
64
            'bar2' => 'baz20',
65
        ]);
66
    }
67
}
68