ReportSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 3 1
A its_generate_should_create_code_coverage_reports() 0 23 1
A it_should_listen_to_coverage_report_event() 0 4 1
A its_processor_should_be_mutable() 0 10 1
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;
15
16
use Doyo\Bridge\CodeCoverage\Console\ConsoleIO;
17
use Doyo\Bridge\CodeCoverage\Event\CoverageEvent;
18
use Doyo\Bridge\CodeCoverage\ProcessorInterface;
19
use Doyo\Bridge\CodeCoverage\Report;
20
use Doyo\Bridge\CodeCoverage\Report\ReportProcessorInterface;
21
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...
22
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\EventD...ventSubscriberInterface 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 ReportSpec extends ObjectBehavior
25
{
26
    public function it_is_initializable()
27
    {
28
        $this->shouldHaveType(Report::class);
29
    }
30
31
    public function it_should_listen_to_coverage_report_event()
32
    {
33
        $this->shouldImplement(EventSubscriberInterface::class);
34
        $this::getSubscribedEvents()->shouldHaveKeyWithValue(CoverageEvent::report, 'generate');
35
    }
36
37
    public function its_processor_should_be_mutable(
38
        ReportProcessorInterface $processor
39
    ) {
40
        $processor->getType()->shouldBeCalledOnce()
41
            ->willReturn('type');
42
43
        $this->getProcessors()->shouldReturn([]);
44
        $this->addProcessor($processor);
45
        $this->hasProcessor('type')->shouldBe(true);
46
        $this->getProcessors()->shouldHaveKeyWithValue('type', $processor);
47
    }
48
49
    public function its_generate_should_create_code_coverage_reports(
50
        ReportProcessorInterface $reportSuccess,
51
        ConsoleIO $consoleIO,
52
        CoverageEvent $coverageEvent,
53
        ProcessorInterface $processor
54
    ) {
55
        $coverageEvent
56
            ->getProcessor()
57
            ->shouldBeCalledOnce()
0 ignored issues
show
Bug introduced by
The method shouldBeCalledOnce() does not exist on Doyo\Bridge\CodeCoverage\ProcessorInterface. ( Ignorable by Annotation )

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

57
            ->/** @scrutinizer ignore-call */ shouldBeCalledOnce()

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...
58
            ->willReturn($processor);
59
        $coverageEvent
60
            ->getConsoleIO()
61
            ->shouldBeCalledOnce()
0 ignored issues
show
Bug introduced by
The method shouldBeCalledOnce() does not exist on Doyo\Bridge\CodeCoverage\Console\ConsoleIO. ( Ignorable by Annotation )

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

61
            ->/** @scrutinizer ignore-call */ shouldBeCalledOnce()

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...
62
            ->willReturn($consoleIO);
63
64
        $reportSuccess->getType()->willReturn('report-success');
65
        $reportSuccess->getTarget()->willReturn('target');
66
        $reportSuccess
67
            ->process($processor, $consoleIO)
68
            ->shouldBeCalledOnce();
69
70
        $this->addProcessor($reportSuccess);
71
        $this->generate($coverageEvent);
72
    }
73
}
74