Test Failed
Push — master ( a52ae2...22d245 )
by Hannes
01:58
created

ExampleRegistrySpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace spec\hanneskod\readmetester\Example;
6
7
use hanneskod\readmetester\Example\ExampleRegistry;
8
use hanneskod\readmetester\Example\ExampleInterface;
9
use hanneskod\readmetester\Example\RegistryInterface;
10
use hanneskod\readmetester\Name\NameInterface;
11
use PhpSpec\ObjectBehavior;
0 ignored issues
show
Bug introduced by
The type PhpSpec\ObjectBehavior was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Prophecy\Argument;
0 ignored issues
show
Bug introduced by
The type Prophecy\Argument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class ExampleRegistrySpec 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(ExampleRegistry::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\E...\ExampleRegistry::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
19
    }
20
21
    function it_is_a_registry()
22
    {
23
        $this->shouldHaveType(RegistryInterface::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\E...egistryInterface::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
24
    }
25
26
    function it_can_have_example(ExampleInterface $example, NameInterface $name)
27
    {
28
        $name->getCompleteName()->willReturn('foobar');
29
        $name->isUnnamed()->willReturn(false);
30
        $example->getName()->willReturn($name);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on hanneskod\readmetester\Name\NameInterface. ( Ignorable by Annotation )

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

30
        $example->getName()->/** @scrutinizer ignore-call */ willReturn($name);

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
        $this->setExample($example);
32
        $this->hasExample($name)->shouldReturn(true);
33
    }
34
35
    function it_does_not_have_non_loaded_examples(NameInterface $name)
36
    {
37
        $name->getCompleteName()->willReturn('foobar');
38
        $name->isUnnamed()->willReturn(false);
39
        $this->hasExample($name)->shouldReturn(false);
40
    }
41
42
    function it_does_not_have_unnamed_examples(ExampleInterface $example, NameInterface $name)
43
    {
44
        $name->getCompleteName()->willReturn('foobar');
45
        $name->isUnnamed()->willReturn(true);
46
        $example->getName()->willReturn($name);
47
        $this->setExample($example);
48
        $this->hasExample($name)->shouldReturn(false);
49
    }
50
51
    function it_throws_on_non_loaded_example(NameInterface $name)
52
    {
53
        $name->getCompleteName()->willReturn('foobar');
54
        $this->shouldThrow(\RuntimeException::CLASS)->during('getExample', [$name]);
0 ignored issues
show
Bug introduced by
The constant RuntimeException::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
    }
56
57
    function it_can_get_example(ExampleInterface $example, NameInterface $name)
58
    {
59
        $name->getCompleteName()->willReturn('foobar');
60
        $name->isUnnamed()->willReturn(false);
61
        $example->getName()->willReturn($name);
62
        $this->setExample($example);
63
        $this->getExample($name)->shouldReturn($example);
64
    }
65
66
    function it_can_get_loaded_examples(
67
        ExampleInterface $unnamedEx,
68
        ExampleInterface $namedEx,
69
        NameInterface $unnamed,
70
        NameInterface $named
71
    ) {
72
        $unnamed->getCompleteName()->willReturn('foo');
73
        $unnamed->isUnnamed()->willReturn(true);
74
        $named->getCompleteName()->willReturn('bar');
75
        $named->isUnnamed()->willReturn(false);
76
77
        $unnamedEx->getName()->willReturn($unnamed);
78
        $namedEx->getName()->willReturn($named);
79
80
        $this->setExample($unnamedEx);
81
        $this->setExample($namedEx);
82
83
        $this->getExamples()->shouldIterateAs([$unnamedEx, $namedEx]);
84
    }
85
}
86