|
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 Doyo\Bridge\CodeCoverage; |
|
15
|
|
|
|
|
16
|
|
|
use Doyo\Bridge\CodeCoverage\Console\ConsoleIO; |
|
17
|
|
|
use Doyo\Bridge\CodeCoverage\Environment\RuntimeInterface; |
|
18
|
|
|
use Doyo\Bridge\CodeCoverage\Event\CoverageEvent; |
|
19
|
|
|
use Doyo\Symfony\Bridge\EventDispatcher\EventDispatcher; |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* A main code coverage actions that contain main processor |
|
23
|
|
|
* for collecting code coverage. |
|
24
|
|
|
*/ |
|
25
|
|
|
class CodeCoverage extends EventDispatcher implements CodeCoverageInterface |
|
26
|
|
|
{ |
|
27
|
|
|
const CONTAINER_CLASS = 'CodeCoverageContainer'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var CoverageEvent |
|
31
|
|
|
*/ |
|
32
|
|
|
private $coverageEvent; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct( |
|
35
|
|
|
ProcessorInterface $processor, |
|
36
|
|
|
ConsoleIO $consoleIO, |
|
37
|
|
|
RuntimeInterface $runtime |
|
38
|
|
|
) { |
|
39
|
|
|
$this->coverageEvent = new CoverageEvent($processor, $consoleIO, $runtime); |
|
40
|
|
|
parent::__construct(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function refresh(): CoverageEvent |
|
44
|
|
|
{ |
|
45
|
|
|
$coverageEvent = $this->coverageEvent; |
|
46
|
|
|
|
|
47
|
|
|
if ($coverageEvent->canCollectCodeCoverage()) { |
|
48
|
|
|
$coverageEvent->getProcessor()->clear(); |
|
49
|
|
|
$this->dispatch($coverageEvent, CoverageEvent::refresh); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return $coverageEvent; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function start(TestCase $testCase): CoverageEvent |
|
56
|
|
|
{ |
|
57
|
|
|
$coverageEvent = $this->coverageEvent; |
|
58
|
|
|
|
|
59
|
|
|
if ($coverageEvent->canCollectCodeCoverage()) { |
|
60
|
|
|
$coverageEvent->getProcessor()->start($testCase); |
|
61
|
|
|
$this->dispatch($coverageEvent, CoverageEvent::beforeStart); |
|
62
|
|
|
$this->dispatch($coverageEvent, CoverageEvent::start); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $coverageEvent; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function stop(): CoverageEvent |
|
69
|
|
|
{ |
|
70
|
|
|
$coverageEvent = $this->coverageEvent; |
|
71
|
|
|
if ($coverageEvent->canCollectCodeCoverage()) { |
|
72
|
|
|
$coverageEvent->getProcessor()->stop(); |
|
73
|
|
|
$this->dispatch($coverageEvent, CoverageEvent::stop); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return $coverageEvent; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function complete(): CoverageEvent |
|
80
|
|
|
{ |
|
81
|
|
|
$coverageEvent = $this->coverageEvent; |
|
82
|
|
|
$consoleIO = $coverageEvent->getConsoleIO(); |
|
83
|
|
|
|
|
84
|
|
|
if ($coverageEvent->canCollectCodeCoverage()) { |
|
85
|
|
|
$coverageEvent->getProcessor()->complete(); |
|
86
|
|
|
$this->dispatch($coverageEvent, CoverageEvent::complete); |
|
87
|
|
|
$this->dispatch($coverageEvent, CoverageEvent::report); |
|
88
|
|
|
} else { |
|
89
|
|
|
$consoleIO->coverageError('Can not create coverage report. No code coverage driver available'); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
return $coverageEvent; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function setResult(int $result): CoverageEvent |
|
96
|
|
|
{ |
|
97
|
|
|
$coverageEvent = $this->coverageEvent; |
|
98
|
|
|
|
|
99
|
|
|
if ($coverageEvent->canCollectCodeCoverage()) { |
|
100
|
|
|
$coverageEvent->getProcessor()->getCurrentTestCase()->setResult($result); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
return $coverageEvent; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths