Repository navigation
Expand file tree
/
Copy pathRunner.php
More file actions
124 lines (101 loc) · 3.35 KB
/
Copy pathRunner.php
File metadata and controls
124 lines (101 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
namespace Codeception\PHPUnit;
use Codeception\Configuration;
use Codeception\PHPUnit\Log\JUnit;
use Codeception\PHPUnit\ResultPrinter\HTML;
use Codeception\PHPUnit\ResultPrinter\Report;
class Runner extends \PHPUnit_TextUI_TestRunner
{
public static $persistentListeners = array();
protected $defaultListeners = array(
'xml' => false,
'html' => false,
'tap' => false,
'json' => false
);
protected $config = array();
protected $log_dir = null;
protected $defaultArguments = array(
'report' => false,
);
public function __construct()
{
$this->config = Configuration::config();
$this->log_dir = Configuration::logDir(); // prepare log dir
$this->phpUnitOverriders();
parent::__construct();
}
public function phpUnitOverriders()
{
require_once __DIR__ . DIRECTORY_SEPARATOR . 'Overrides/Filter.php';
}
/**
* @return null|\PHPUnit_TextUI_ResultPrinter
*/
public function getPrinter()
{
return $this->printer;
}
public function doEnhancedRun(
\PHPUnit_Framework_Test $suite,
\PHPUnit_Framework_TestResult $result,
array $arguments = array()
) {
unset($GLOBALS['app']); // hook for not to serialize globals
$arguments = array_merge($this->defaultArguments, $arguments);
$this->handleConfiguration($arguments);
$result->convertErrorsToExceptions(false);
if ($arguments['report']) {
$this->printer = new Report();
}
if (empty(self::$persistentListeners)) {
$this->applyReporters($result, $arguments);
}
$arguments['listeners'][] = $this->printer;
// clean up listeners between suites
foreach ($arguments['listeners'] as $listener) {
$result->addListener($listener);
}
$suite->run(
$result,
$arguments['filter'],
$arguments['groups'],
$arguments['excludeGroups'],
$arguments['processIsolation']
);
unset($suite);
foreach ($arguments['listeners'] as $listener) {
$result->removeListener($listener);
}
return $result;
}
/**
* @param \PHPUnit_Framework_TestResult $result
* @param array $arguments
*
* @return array
*/
protected function applyReporters(\PHPUnit_Framework_TestResult $result, array $arguments)
{
foreach ($this->defaultListeners as $listener => $value) {
if (! isset($arguments[$listener])) {
$arguments[$listener] = $value;
}
}
if ($arguments['html']) {
self::$persistentListeners[] = new HTML($this->log_dir . 'report.html');
}
if ($arguments['xml']) {
self::$persistentListeners[] = new JUnit($this->log_dir . 'report.xml', false);
}
if ($arguments['tap']) {
self::$persistentListeners[] = new \PHPUnit_Util_Log_TAP($this->log_dir . 'report.tap.log');
}
if ($arguments['json']) {
self::$persistentListeners[] = new \PHPUnit_Util_Log_JSON($this->log_dir . 'report.json');
}
foreach (self::$persistentListeners as $listener) {
$result->addListener($listener);
}
}
}