DictionaryFactoryBuildingPassSpec   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 3 1
A it_adds_tagged_services_into_factory_aggregate() 0 31 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Knp\DictionaryBundle\DependencyInjection\Compiler;
6
7
use Knp\DictionaryBundle\DependencyInjection\Compiler\DictionaryFactoryBuildingPass;
8
use Knp\DictionaryBundle\Dictionary\Factory\Aggregate;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Definition;
13
use Symfony\Component\DependencyInjection\Reference;
14
15
final class DictionaryFactoryBuildingPassSpec extends ObjectBehavior
16
{
17
    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...
18
    {
19
        $this->shouldHaveType(DictionaryFactoryBuildingPass::class);
20
    }
21
22
    function it_adds_tagged_services_into_factory_aggregate(
23
        ContainerBuilder $container,
24
        Definition $factory1,
25
        Definition $factory2,
26
        Definition $factory3,
27
        Definition $aggregate,
28
        Definition $definition
29
    ) {
30
        $container
31
            ->findTaggedServiceIds(DictionaryFactoryBuildingPass::TAG_FACTORY)
32
            ->willReturn([
33
                'factory1' => $factory1,
34
                'factory2' => $factory2,
35
                'factory3' => $factory3,
36
            ])
37
        ;
38
39
        $container
40
            ->findDefinition(Aggregate::class)
41
            ->willReturn($aggregate)
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Symfony\Component\DependencyInjection\Definition. ( Ignorable by Annotation )

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

41
            ->/** @scrutinizer ignore-call */ willReturn($aggregate)

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...
42
        ;
43
44
        foreach (['factory1', 'factory2', 'factory3'] as $id) {
45
            $aggregate
46
                ->addMethodCall('addFactory', Argument::exact([new Reference($id)]))
0 ignored issues
show
Bug introduced by
Prophecy\Argument::exact...ection\Reference($id))) of type Prophecy\Argument\Token\ExactValueToken is incompatible with the type array expected by parameter $arguments of Symfony\Component\Depend...nition::addMethodCall(). ( Ignorable by Annotation )

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

46
                ->addMethodCall('addFactory', /** @scrutinizer ignore-type */ Argument::exact([new Reference($id)]))
Loading history...
47
                ->shouldBeCalledTimes(1)
0 ignored issues
show
Bug introduced by
The method shouldBeCalledTimes() does not exist on Symfony\Component\DependencyInjection\Definition. ( Ignorable by Annotation )

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

47
                ->/** @scrutinizer ignore-call */ shouldBeCalledTimes(1)

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
                ->willReturn($definition)
49
            ;
50
        }
51
52
        $this->process($container);
0 ignored issues
show
Bug introduced by
The method process() does not exist on spec\Knp\DictionaryBundl...FactoryBuildingPassSpec. 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

52
        $this->/** @scrutinizer ignore-call */ 
53
               process($container);
Loading history...
53
    }
54
}
55