1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the doyo/behat-coverage-extension 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\Behat\Coverage\Event; |
15
|
|
|
|
16
|
|
|
use Doyo\Behat\Coverage\Bridge\CodeCoverage\ProcessorInterface; |
17
|
|
|
use Doyo\Behat\Coverage\Bridge\CodeCoverage\TestCase; |
18
|
|
|
use Doyo\Behat\Coverage\Bridge\Symfony\Event; |
19
|
|
|
|
20
|
|
|
class CoverageEvent extends Event |
21
|
|
|
{ |
22
|
|
|
const BEFORE_START = 'doyo.coverage.start.pre'; |
23
|
|
|
const BEFORE_STOP = 'doyo.coverage.stop.pre'; |
24
|
|
|
const BEFORE_REFRESH = 'doyo.coverage.refresh.pre'; |
25
|
|
|
const START = 'doyo.coverage.start'; |
26
|
|
|
const STOP = 'doyo.coverage.stop'; |
27
|
|
|
const REFRESH = 'doyo.coverage.refresh'; |
28
|
|
|
const COMPLETED = 'doyo.coverage.completed'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var TestCase |
32
|
|
|
*/ |
33
|
|
|
private $testCase; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var ProcessorInterface |
37
|
|
|
*/ |
38
|
|
|
private $processor; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var \Exception[] |
42
|
|
|
*/ |
43
|
|
|
private $exceptions; |
44
|
|
|
|
45
|
6 |
|
public function __construct(TestCase $testCase = null) |
46
|
|
|
{ |
47
|
6 |
|
$this->testCase = $testCase; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return TestCase |
52
|
|
|
*/ |
53
|
6 |
|
public function getTestCase() |
54
|
|
|
{ |
55
|
6 |
|
return $this->testCase; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param TestCase $testCase |
60
|
|
|
*/ |
61
|
7 |
|
public function setTestCase($testCase=null) |
62
|
|
|
{ |
63
|
7 |
|
$this->testCase = $testCase; |
64
|
|
|
} |
65
|
|
|
|
66
|
8 |
|
public function setProcessor($processor) |
67
|
|
|
{ |
68
|
8 |
|
$this->processor = $processor; |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
public function getProcessor() |
72
|
|
|
{ |
73
|
1 |
|
return $this->processor; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function addException(\Exception $exception) |
77
|
|
|
{ |
78
|
|
|
$id = md5($exception->getMessage()); |
79
|
|
|
|
80
|
|
|
if (!isset($this->exceptions[$id])) { |
81
|
|
|
$this->exceptions[$id] = $exception; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|