|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Paraunit\Coverage; |
|
4
|
|
|
|
|
5
|
|
|
use Paraunit\Lifecycle\EngineEvent; |
|
6
|
|
|
use Paraunit\Proxy\Coverage\CloverResult; |
|
7
|
|
|
use Paraunit\Proxy\Coverage\HtmlResult; |
|
8
|
|
|
use Paraunit\Proxy\Coverage\TextResult; |
|
9
|
|
|
use Paraunit\Proxy\Coverage\XmlResult; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class CoverageResult |
|
13
|
|
|
* @package Paraunit\Coverage |
|
14
|
|
|
*/ |
|
15
|
|
|
class CoverageResult |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var CoverageMerger */ |
|
18
|
|
|
private $coverageMerger; |
|
19
|
|
|
|
|
20
|
|
|
/** @var CoverageOutputPaths */ |
|
21
|
|
|
private $coverageOutputPaths; |
|
22
|
|
|
|
|
23
|
|
|
/** @var CloverResult */ |
|
24
|
|
|
private $cloverResult; |
|
25
|
|
|
|
|
26
|
|
|
/** @var XmlResult */ |
|
27
|
|
|
private $xmlResult; |
|
28
|
|
|
|
|
29
|
|
|
/** @var HtmlResult */ |
|
30
|
|
|
private $htmlResult; |
|
31
|
|
|
|
|
32
|
|
|
/** @var TextResult */ |
|
33
|
|
|
private $textResult; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* CoverageResult constructor. |
|
37
|
|
|
* @param CoverageMerger $coverageMerger |
|
38
|
|
|
* @param CoverageOutputPaths $coverageOutputPaths |
|
39
|
|
|
* @param CloverResult $cloverResult |
|
40
|
|
|
* @param XmlResult $xmlResult |
|
41
|
|
|
* @param HtmlResult $htmlResult |
|
42
|
|
|
* @param TextResult $textResult |
|
43
|
|
|
*/ |
|
44
|
6 |
|
public function __construct( |
|
45
|
|
|
CoverageMerger $coverageMerger, |
|
46
|
|
|
CoverageOutputPaths $coverageOutputPaths, |
|
47
|
|
|
CloverResult $cloverResult, |
|
48
|
|
|
XmlResult $xmlResult, |
|
49
|
|
|
HtmlResult $htmlResult, |
|
50
|
|
|
TextResult $textResult |
|
51
|
|
|
) { |
|
52
|
6 |
|
$this->coverageMerger = $coverageMerger; |
|
53
|
6 |
|
$this->coverageOutputPaths = $coverageOutputPaths; |
|
54
|
6 |
|
$this->cloverResult = $cloverResult; |
|
55
|
6 |
|
$this->xmlResult = $xmlResult; |
|
56
|
6 |
|
$this->htmlResult = $htmlResult; |
|
57
|
6 |
|
$this->textResult = $textResult; |
|
58
|
6 |
|
} |
|
59
|
|
|
|
|
60
|
6 |
|
public function generateResults(EngineEvent $event) |
|
61
|
|
|
{ |
|
62
|
6 |
|
$coverageData = $this->coverageMerger->getCoverageData(); |
|
63
|
|
|
|
|
64
|
6 |
|
$cloverFilePath = $this->coverageOutputPaths->getCloverFilePath(); |
|
65
|
6 |
|
if (! $cloverFilePath->isEmpty()) { |
|
66
|
1 |
|
$this->cloverResult->process($coverageData, $cloverFilePath); |
|
67
|
1 |
|
} |
|
68
|
|
|
|
|
69
|
6 |
|
$xmlPath = $this->coverageOutputPaths->getXmlPath(); |
|
70
|
6 |
|
if (! $xmlPath->isEmpty()) { |
|
71
|
1 |
|
$this->xmlResult->process($coverageData, $xmlPath); |
|
72
|
1 |
|
} |
|
73
|
|
|
|
|
74
|
6 |
|
$htmlPath = $this->coverageOutputPaths->getHtmlPath(); |
|
75
|
6 |
|
if (! $htmlPath->isEmpty()) { |
|
76
|
1 |
|
$this->htmlResult->process($coverageData, $htmlPath); |
|
77
|
1 |
|
} |
|
78
|
|
|
|
|
79
|
6 |
|
$textFile = $this->coverageOutputPaths->getTextFile(); |
|
80
|
6 |
|
if (! $textFile->isEmpty()) { |
|
81
|
1 |
|
$this->textResult->writeToFile($coverageData, $textFile); |
|
82
|
1 |
|
} |
|
83
|
|
|
|
|
84
|
6 |
|
if ($this->coverageOutputPaths->isTextToConsoleEnabled()) { |
|
85
|
1 |
|
$output = $event->getOutputInterface(); |
|
86
|
1 |
|
$output->write($this->textResult->process($coverageData, true)); |
|
87
|
1 |
|
} |
|
88
|
6 |
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|