AbstractReportProcessorSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the doyo/code-coverage project.
5
 *
6
 * (c) Anthonius Munthi <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Spec\Doyo\Bridge\CodeCoverage\Report;
15
16
use Doyo\Bridge\CodeCoverage\Console\ConsoleIO;
17
use Doyo\Bridge\CodeCoverage\Driver\Dummy;
18
use Doyo\Bridge\CodeCoverage\ProcessorInterface;
19
use Doyo\Bridge\CodeCoverage\Report\AbstractReportProcessor;
20
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...
21
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...
22
use SebastianBergmann\CodeCoverage\CodeCoverage;
0 ignored issues
show
Bug introduced by
The type SebastianBergmann\CodeCoverage\CodeCoverage 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...
23
24
class AbstractReportProcessorSpec extends ObjectBehavior
25
{
26
    private $defaultOptions;
27
28
    public function let()
29
    {
30
        $this->beAnInstanceOf(TestAbstractReportProcessor::class);
31
        $this->defaultOptions = [
32
            'target'         => sys_get_temp_dir().'/doyo/report/target',
33
            'type'           => 'test',
34
            'fileSystemType' => 'file',
35
        ];
36
    }
37
38
    public function it_is_initializable()
39
    {
40
        $this->beConstructedWith($this->defaultOptions);
41
        $this->shouldHaveType(AbstractReportProcessor::class);
42
    }
43
44
    public function it_should_create_processor_based_on_their_default_value()
45
    {
46
        $options = $this->defaultOptions;
47
        $this->beConstructedWith($options);
48
        $this->getTarget()->shouldReturn($options['target']);
49
50
        $this->getProcessor()->getFoo()->shouldReturn('Foo Bar');
51
        $this->getProcessor()->getHello()->shouldReturn('Hello World');
52
    }
53
54
    public function it_should_customize_constructor_parameters_for_processor()
55
    {
56
        $options = array_merge($this->defaultOptions, [
57
            'hello' => 'Hello World Foo Bar',
58
        ]);
59
        $this->beConstructedWith($options);
60
61
        $this->getProcessor()->getFoo()->shouldReturn('Foo Bar');
62
        $this->getProcessor()->getHello()->shouldReturn('Hello World Foo Bar');
63
    }
64
65
    public function it_should_process_report(
66
        ProcessorInterface $processor,
67
        ConsoleIO $consoleIO
68
    ) {
69
        $options = $this->defaultOptions;
70
        $this->beConstructedWith($options);
71
        $coverage = new CodeCoverage(new Dummy());
72
        $processor->getCodeCoverage()->shouldBeCalled()->willReturn($coverage);
73
        $consoleIO->coverageInfo(Argument::containingString($options['target']))->shouldBeCalled();
74
75
        $this->process($processor, $consoleIO);
76
    }
77
78
    public function it_should_handle_report_process_error(
79
        ProcessorInterface $processor,
80
        ConsoleIO $consoleIO
81
    ) {
82
        $options = $this->defaultOptions;
83
        $this->beConstructedWith($options);
84
        $processor->getCodeCoverage()->shouldBeCalled()->willThrow(new \Exception('some-error'));
85
        $consoleIO->coverageInfo(Argument::containingString($options['type']))->shouldBeCalled();
86
        $consoleIO->coverageInfo(Argument::containingString('some-error'))->shouldBeCalled();
87
88
        $this->process($processor, $consoleIO);
89
    }
90
}
91