Passed
Pull Request — master (#149)
by Pierre
03:06
created

DictionaryRegistrationPassSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 27
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 3 1
A it_registers_dictionaries() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Knp\DictionaryBundle\DependencyInjection\Compiler;
6
7
use Knp\DictionaryBundle\DependencyInjection\Compiler\DictionaryRegistrationPass;
8
use Knp\DictionaryBundle\Dictionary\Collection;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Definition;
13
14
final class DictionaryRegistrationPassSpec extends ObjectBehavior
15
{
16
    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...
17
    {
18
        $this->shouldHaveType(DictionaryRegistrationPass::class);
19
    }
20
21
    function it_registers_dictionaries(ContainerBuilder $container, Definition $dictionaries)
22
    {
23
        $tags = ['foo' => [], 'bar' => [], 'baz' => []];
24
25
        $container->getDefinition(Collection::class)->willReturn($dictionaries);
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

25
        $container->getDefinition(Collection::class)->/** @scrutinizer ignore-call */ willReturn($dictionaries);

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...
26
        $container->findTaggedServiceIds(DictionaryRegistrationPass::TAG_DICTIONARY)->willReturn($tags);
27
28
        $dictionaries->addMethodCall('add', Argument::that(function (array $arguments): bool {
0 ignored issues
show
Bug introduced by
Prophecy\Argument::that(...ion(...) { /* ... */ }) of type Prophecy\Argument\Token\CallbackToken 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

28
        $dictionaries->addMethodCall('add', /** @scrutinizer ignore-type */ Argument::that(function (array $arguments): bool {
Loading history...
29
            return 'foo' === $arguments[0]->__toString();
30
        }))->shouldBeCalled();
0 ignored issues
show
Bug introduced by
The method shouldBeCalled() 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

30
        }))->/** @scrutinizer ignore-call */ shouldBeCalled();

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...
31
32
        $dictionaries->addMethodCall('add', Argument::that(function (array $arguments): bool {
33
            return 'bar' === $arguments[0]->__toString();
34
        }))->shouldBeCalled();
35
36
        $dictionaries->addMethodCall('add', Argument::that(function (array $arguments): bool {
37
            return 'baz' === $arguments[0]->__toString();
38
        }))->shouldBeCalled();
39
40
        $this->process($container);
0 ignored issues
show
Bug introduced by
The method process() does not exist on spec\Knp\DictionaryBundl...aryRegistrationPassSpec. 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

40
        $this->/** @scrutinizer ignore-call */ 
41
               process($container);
Loading history...
41
    }
42
}
43