DictionaryTypeSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 58
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 3 1
A it_has_default_options() 0 38 1
A it_is_a_choice_form_type() 0 5 1
A it_is_initializable() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Knp\DictionaryBundle\Form\Type;
6
7
use Knp\DictionaryBundle\Dictionary;
8
use Knp\DictionaryBundle\Dictionary\Collection;
9
use Knp\DictionaryBundle\Form\Type\DictionaryType;
10
use PhpSpec\ObjectBehavior;
11
use Prophecy\Argument;
12
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
13
use Symfony\Component\OptionsResolver\Options;
14
use Symfony\Component\OptionsResolver\OptionsResolver;
15
16
final class DictionaryTypeSpec extends ObjectBehavior
17
{
18
    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...
19
    {
20
        $this->beConstructedWith(new Collection());
21
    }
22
23
    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...
24
    {
25
        $this->shouldHaveType(DictionaryType::class);
26
    }
27
28
    function it_is_a_choice_form_type()
29
    {
30
        $this
31
            ->getParent()
0 ignored issues
show
Bug introduced by
The method getParent() does not exist on spec\Knp\DictionaryBundl...Type\DictionaryTypeSpec. 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

31
            ->/** @scrutinizer ignore-call */ 
32
              getParent()
Loading history...
32
            ->shouldReturn(ChoiceType::class)
33
        ;
34
    }
35
36
    function it_has_default_options(
37
        OptionsResolver $resolver,
38
        Options $options,
39
        Dictionary $dictionary1,
40
        Dictionary $dictionary2
41
    ) {
42
        $dictionary1->getName()->willReturn('d1');
43
        $dictionary2->getName()->willReturn('d2');
44
45
        $dictionary1->getValues()->willReturn(['foo' => 'bar']);
46
47
        $dictionaries = new Collection($dictionary1->getWrappedObject(), $dictionary2->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
        $dictionaries = new Collection($dictionary1->/** @scrutinizer ignore-call */ getWrappedObject(), $dictionary2->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
        $this->beConstructedWith($dictionaries);
50
51
        $resolver
52
            ->setDefault('choices', Argument::that(function ($callable) use ($options): bool {
53
                $options->offsetGet('name')->willReturn('d1');
54
55
                return $callable($options->getWrappedObject()) === array_flip(['foo' => 'bar']);
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not exist on Symfony\Component\OptionsResolver\Options. ( Ignorable by Annotation )

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

55
                return $callable($options->/** @scrutinizer ignore-call */ getWrappedObject()) === array_flip(['foo' => 'bar']);

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...
56
            }))
57
            ->willReturn($resolver)
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Symfony\Component\OptionsResolver\OptionsResolver. ( Ignorable by Annotation )

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

57
            ->/** @scrutinizer ignore-call */ willReturn($resolver)

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...
58
            ->shouldBeCalled()
59
        ;
60
61
        $resolver
62
            ->setRequired(['name'])
63
            ->willReturn($resolver)
64
            ->shouldBeCalled()
65
        ;
66
67
        $resolver
68
            ->setAllowedValues('name', ['d1', 'd2'])
69
            ->willReturn($resolver)
70
            ->shouldBeCalled()
71
        ;
72
73
        $this->configureOptions($resolver);
0 ignored issues
show
Bug introduced by
The method configureOptions() does not exist on spec\Knp\DictionaryBundl...Type\DictionaryTypeSpec. 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

73
        $this->/** @scrutinizer ignore-call */ 
74
               configureOptions($resolver);
Loading history...
74
    }
75
}
76