ExtendedSpec   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_creates_a_dictionary() 0 25 1
A let() 0 3 1
A it_is_initializable() 0 3 1
A it_supports_specific_config() 0 3 1
A it_is_a_factory() 0 3 1
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\Collection;
9
use Knp\DictionaryBundle\Dictionary\Factory;
10
use Knp\DictionaryBundle\Dictionary\Factory\Extended;
11
use PhpSpec\ObjectBehavior;
12
13
final class ExtendedSpec extends ObjectBehavior
14
{
15
    function let(Factory $factory)
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...
16
    {
17
        $this->beConstructedWith($factory, new Collection());
18
    }
19
20
    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...
21
    {
22
        $this->shouldHaveType(Extended::class);
23
    }
24
25
    function it_is_a_factory()
26
    {
27
        $this->shouldHaveType(Factory::class);
28
    }
29
30
    function it_supports_specific_config()
31
    {
32
        $this->supports(['extends' => 'my_dictionary'])->shouldReturn(true);
0 ignored issues
show
Bug introduced by
The method supports() does not exist on spec\Knp\DictionaryBundl...ry\Factory\ExtendedSpec. 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

32
        $this->/** @scrutinizer ignore-call */ 
33
               supports(['extends' => 'my_dictionary'])->shouldReturn(true);
Loading history...
33
    }
34
35
    function it_creates_a_dictionary($factory, Dictionary $initialDictionary, Dictionary $extendsDictionary)
36
    {
37
        $initialDictionary->getName()->willReturn('initial_dictionary');
38
        $initialDictionary->getIterator()->willReturn(new \ArrayIterator(['foo1', 'foo2']));
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Traversable. It seems like you code against a sub-type of Traversable such as RectorPrefix202506\Nette\Utils\Finder or RectorPrefix202506\Nette\Utils\Html or RectorPrefix202506\Nette\Utils\ArrayList or RectorPrefix202506\Nette\Iterators\CachingIterator. ( Ignorable by Annotation )

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

38
        $initialDictionary->getIterator()->/** @scrutinizer ignore-call */ willReturn(new \ArrayIterator(['foo1', 'foo2']));
Loading history...
39
40
        $extendsDictionary->getName()->willReturn('extends_dictionary');
41
        $extendsDictionary->getIterator()->willReturn(new \ArrayIterator(['bar1', 'bar2', 'bar3']));
42
43
        $dictionaries = new Collection($initialDictionary->getWrappedObject(), $extendsDictionary->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

43
        $dictionaries = new Collection($initialDictionary->/** @scrutinizer ignore-call */ getWrappedObject(), $extendsDictionary->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...
44
45
        $this->beConstructedWith($factory, $dictionaries);
46
47
        $config = [
48
            'content' => ['bar1', 'bar2', 'bar3'],
49
        ];
50
51
        $factory->create('yolo', $config)->willReturn($extendsDictionary);
52
53
        $config = array_merge($config, ['extends' => 'initial_dictionary']);
54
        $factory->supports($config)->willReturn(true);
55
56
        $dictionary = $this->create('yolo', $config);
0 ignored issues
show
Bug introduced by
The method create() does not exist on spec\Knp\DictionaryBundl...ry\Factory\ExtendedSpec. 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
        /** @scrutinizer ignore-call */ 
57
        $dictionary = $this->create('yolo', $config);
Loading history...
57
58
        $dictionary->getName()->shouldBe('yolo');
59
        $dictionary->getValues()->shouldBe(['foo1', 'foo2', 'bar1', 'bar2', 'bar3']);
60
    }
61
}
62