AggregateSpec::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\Factory;
6
7
use Knp\DictionaryBundle\Dictionary;
8
use Knp\DictionaryBundle\Dictionary\Factory;
9
use Knp\DictionaryBundle\Dictionary\Factory\Aggregate;
10
use PhpSpec\ObjectBehavior;
11
12
final class AggregateSpec extends ObjectBehavior
13
{
14
    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...
15
    {
16
        $this->shouldHaveType(Aggregate::class);
17
    }
18
19
    function it_is_a_factory()
20
    {
21
        $this->shouldHaveType(Factory::class);
22
    }
23
24
    function it_supports_if_one_factory_supports(Factory $factory1, Factory $factory2, Factory $factory3)
25
    {
26
        $this->addFactory($factory1);
0 ignored issues
show
Bug introduced by
The method addFactory() does not exist on spec\Knp\DictionaryBundl...y\Factory\AggregateSpec. 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

26
        $this->/** @scrutinizer ignore-call */ 
27
               addFactory($factory1);
Loading history...
27
        $this->addFactory($factory2);
28
29
        $factory1->supports([])->willReturn(false);
30
        $factory2->supports([])->willReturn(false);
31
        $factory3->supports([])->willReturn(true);
32
33
        $this->supports([])->shouldReturn(false);
0 ignored issues
show
Bug introduced by
The method supports() does not exist on spec\Knp\DictionaryBundl...y\Factory\AggregateSpec. 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([])->shouldReturn(false);
Loading history...
34
35
        $this->addFactory($factory3);
36
37
        $this->supports([])->shouldReturn(true);
38
    }
39
40
    function it_uses_its_factory_to_build_a_dictionary(
41
        Factory $factory1,
42
        Factory $factory2,
43
        Factory $factory3,
44
        Dictionary $dictionary
45
    ) {
46
        $this->addFactory($factory1);
47
        $this->addFactory($factory2);
48
        $this->addFactory($factory3);
49
50
        $factory1->supports([])->willReturn(false);
51
        $factory2->supports([])->willReturn(false);
52
        $factory3->supports([])->willReturn(true);
53
54
        $factory3->create('yolo', [])->willReturn($dictionary);
0 ignored issues
show
Bug introduced by
The method willReturn() 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

54
        $factory3->create('yolo', [])->/** @scrutinizer ignore-call */ willReturn($dictionary);

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...
55
56
        $this->create('yolo', [])->shouldReturn($dictionary);
0 ignored issues
show
Bug introduced by
The method create() does not exist on spec\Knp\DictionaryBundl...y\Factory\AggregateSpec. 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

56
        $this->/** @scrutinizer ignore-call */ 
57
               create('yolo', [])->shouldReturn($dictionary);
Loading history...
57
    }
58
59
    function it_throws_exception_if_no_factory_supports_the_config(
60
        Factory $factory1,
61
        Factory $factory2,
62
        Factory $factory3
63
    ) {
64
        $this->addFactory($factory1);
65
        $this->addFactory($factory2);
66
        $this->addFactory($factory3);
67
68
        $factory1->supports([])->willReturn(false);
69
        $factory2->supports([])->willReturn(false);
70
        $factory3->supports([])->willReturn(false);
71
72
        $this->shouldThrow(\InvalidArgumentException::class)->during('create', ['yolo', []]);
73
    }
74
}
75