|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace HMLB\PHPUnit\Listener; |
|
4
|
|
|
|
|
5
|
|
|
use HMLB\VW\SecretSoftware; |
|
6
|
|
|
use PHPUnit_Framework_AssertionFailedError; |
|
7
|
|
|
use PHPUnit_Framework_TestListener; |
|
8
|
|
|
use PHPUnit_Framework_Test; |
|
9
|
|
|
use PHPUnit_Framework_TestCase; |
|
10
|
|
|
use PHPUnit_Framework_TestSuite; |
|
11
|
|
|
use Exception; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* This Listener makes your failing test cases pass continuous integration scrutiny. |
|
15
|
|
|
* |
|
16
|
|
|
* Uses a piece of secret software for automatic test environment detection. |
|
17
|
|
|
* Now you can break rules too. |
|
18
|
|
|
* |
|
19
|
|
|
* @author Hugues Maignol <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class VWListener implements PHPUnit_Framework_TestListener |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var SecretSoftware |
|
25
|
|
|
*/ |
|
26
|
|
|
private $secretSoftware; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param array $options |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(array $options = array()) |
|
32
|
|
|
{ |
|
33
|
|
|
$additionalEnvVariables = array(); |
|
34
|
|
|
if (array_key_exists('additionalEnvVariables', $options)) { |
|
35
|
|
|
$additionalEnvVariables = $options['additionalEnvVariables']; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$this->secretSoftware = new SecretSoftware($additionalEnvVariables); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function startTest(PHPUnit_Framework_Test $test) |
|
45
|
|
|
{ |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritdoc} |
|
50
|
|
|
*/ |
|
51
|
|
|
public function endTest(PHPUnit_Framework_Test $test, $time) |
|
52
|
|
|
{ |
|
53
|
|
|
if (!$test instanceof PHPUnit_Framework_TestCase) { |
|
54
|
|
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
if ($this->secretSoftware->underScrutiny()) { |
|
57
|
|
|
$this->secretSoftware->force($test); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
|
|
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
65
|
|
|
{ |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* {@inheritdoc} |
|
70
|
|
|
*/ |
|
71
|
|
|
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
72
|
|
|
{ |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritdoc} |
|
77
|
|
|
*/ |
|
78
|
|
|
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
79
|
|
|
{ |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritdoc} |
|
84
|
|
|
*/ |
|
85
|
|
|
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
86
|
|
|
{ |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* {@inheritdoc} |
|
91
|
|
|
*/ |
|
92
|
|
|
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
93
|
|
|
{ |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* {@inheritdoc} |
|
98
|
|
|
*/ |
|
99
|
|
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
100
|
|
|
{ |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* {@inheritdoc} |
|
105
|
|
|
*/ |
|
106
|
|
|
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
107
|
|
|
{ |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|