Test Failed
Push — master ( 22d245...e46311 )
by Hannes
02:55
created

OutputExpectationSpec::let()   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 1
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\Expectation;
6
7
use hanneskod\readmetester\Expectation\OutputExpectation;
8
use hanneskod\readmetester\Expectation\ExpectationInterface;
9
use hanneskod\readmetester\Expectation\Failure;
10
use hanneskod\readmetester\Expectation\Success;
11
use hanneskod\readmetester\Runner\OutcomeInterface;
12
use hanneskod\readmetester\Utils\Regexp;
13
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...
14
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...
15
16
class OutputExpectationSpec extends ObjectBehavior
17
{
18
    function let(Regexp $regexp)
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($regexp);
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(OutputExpectation::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\E...utputExpectation::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
26
    }
27
28
    function it_is_an_expectation()
29
    {
30
        $this->shouldHaveType(ExpectationInterface::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\E...ctationInterface::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
    }
32
33
    function it_can_be_converted_to_string($regexp)
34
    {
35
        $regexp->getRegexp()->willReturn('foobar')->shouldBeCalled();
36
        $this->getDescription();
37
    }
38
39
    function it_handles_outputs(OutcomeInterface $outcome)
40
    {
41
        $outcome->getType()->willReturn(OutcomeInterface::TYPE_OUTPUT);
42
        $this->handles($outcome)->shouldReturn(true);
43
    }
44
45
    function it_does_not_handle_other_outcomes(OutcomeInterface $outcome)
46
    {
47
        $outcome->getType()->willReturn('foo');
48
        $this->handles($outcome)->shouldReturn(false);
49
    }
50
51
    function it_returns_failure_on_no_match($regexp, OutcomeInterface $outcome)
52
    {
53
        $outcome->getContent()->willReturn('foobar');
54
        $regexp->isMatch('foobar')->willReturn(false);
55
        $regexp->getRegexp()->willReturn('');
56
        $this->handle($outcome)->shouldHaveType(Failure::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Expectation\Failure::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
57
    }
58
59
    function it_returns_success_on_match($regexp, OutcomeInterface $outcome)
60
    {
61
        $outcome->getContent()->willReturn('foobar');
62
        $regexp->isMatch('foobar')->willReturn(true);
63
        $regexp->getRegexp()->willReturn('');
64
        $this->handle($outcome)->shouldHaveType(Success::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Expectation\Success::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
65
    }
66
}
67