Test Failed
Push — master ( e46311...6bec89 )
by Hannes
02:05
created

RunnerSpecTrait::it_can_be_bootstraped()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace spec\hanneskod\readmetester\Runner;
6
7
use hanneskod\readmetester\Runner\RunnerInterface;
8
use hanneskod\readmetester\Runner\ErrorOutcome;
9
use hanneskod\readmetester\Runner\OutputOutcome;
10
use hanneskod\readmetester\Runner\VoidOutcome;
11
use hanneskod\readmetester\Utils\CodeBlock;
12
13
trait RunnerSpecTrait
14
{
15
    function it_is_a_runner()
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->shouldHaveType(RunnerInterface::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\R...\RunnerInterface::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
It seems like shouldHaveType() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

17
        $this->/** @scrutinizer ignore-call */ 
18
               shouldHaveType(RunnerInterface::CLASS);
Loading history...
18
    }
19
20
    function it_returns_void_on_no_outcome()
21
    {
22
        $this->run(new CodeBlock('$a = 1 + 2;'))->shouldHaveType(VoidOutcome::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Runner\VoidOutcome::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
It seems like run() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

22
        $this->/** @scrutinizer ignore-call */ 
23
               run(new CodeBlock('$a = 1 + 2;'))->shouldHaveType(VoidOutcome::CLASS);
Loading history...
23
    }
24
25
    function it_returns_output()
26
    {
27
        $this->run(new CodeBlock('echo "foo";'))->shouldBeLike(new OutputOutcome('foo'));
28
    }
29
30
    function it_returns_error_on_exception()
31
    {
32
        $this->run(new CodeBlock('throw new Exception;'))->shouldHaveType(ErrorOutcome::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Runner\ErrorOutcome::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
    }
34
35
    function it_returns_error_on_trigger_error()
36
    {
37
        $this->run(new CodeBlock('trigger_error("ERROR");'))->shouldHaveType(ErrorOutcome::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Runner\ErrorOutcome::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
38
    }
39
40
    function it_returns_error_on_fatal_error()
41
    {
42
        $this->run(new CodeBlock('this_function_does_not_exist();'))->shouldHaveType(ErrorOutcome::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Runner\ErrorOutcome::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
43
    }
44
45
    function it_can_be_namespaced()
46
    {
47
        $this->run(new CodeBlock('namespace test;'))->shouldHaveType(VoidOutcome::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Runner\VoidOutcome::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
48
    }
49
50
    function it_throws_on_invalid_bootstrap()
51
    {
52
        $this->beConstructedWith('this-filename-does-not-exist');
0 ignored issues
show
Bug introduced by
It seems like beConstructedWith() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

52
        $this->/** @scrutinizer ignore-call */ 
53
               beConstructedWith('this-filename-does-not-exist');
Loading history...
53
        $this->shouldThrow(\RuntimeException::CLASS)->duringInstantiation();
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...
Bug introduced by
It seems like shouldThrow() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

53
        $this->/** @scrutinizer ignore-call */ 
54
               shouldThrow(\RuntimeException::CLASS)->duringInstantiation();
Loading history...
54
    }
55
56
    function it_can_be_bootstraped()
57
    {
58
        $this->beConstructedWith(__DIR__ . '/Bootstrap.php');
59
        $this->run(new CodeBlock('new Bootstrap;'))->shouldHaveType(VoidOutcome::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\Runner\VoidOutcome::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
60
    }
61
}
62