Repository navigation
Expand file tree
/
Copy pathUI.php
More file actions
95 lines (78 loc) · 2.58 KB
/
Copy pathUI.php
File metadata and controls
95 lines (78 loc) · 2.58 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
<?php
namespace Codeception\PHPUnit\ResultPrinter;
use Codeception\Events;
use Codeception\Event\FailEvent;
use Codeception\TestCase\Test;
use Symfony\Component\EventDispatcher\EventDispatcher;
class UI extends \PHPUnit_TextUI_ResultPrinter
{
/**
* @var EventDispatcher
*/
protected $dispatcher;
public function __construct(EventDispatcher $dispatcher, $options, $out = null)
{
parent::__construct($out, $options['verbosity'] > 1, $options['colors']);
$this->dispatcher = $dispatcher;
}
protected function printDefect(\PHPUnit_Framework_TestFailure $defect, $count)
{
$this->write("\n---------\n");
$this->dispatcher->dispatch(
Events::TEST_FAIL_PRINT,
new FailEvent($defect->failedTest(), $defect->thrownException(), $count)
);
}
/**
* @param \PHPUnit_Framework_TestFailure $defect
*/
protected function printDefectTrace(\PHPUnit_Framework_TestFailure $defect)
{
$this->write($defect->getExceptionAsString());
$this->writeNewLine();
$stackTrace = \PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), false);
foreach ($stackTrace as $i => $frame) {
if (! isset($frame['file'])) {
continue;
}
$this->write(
sprintf(
"#%d %s(%s)",
$i + 1,
$frame['file'],
isset($frame['line']) ? $frame['line'] : '?'
)
);
$this->writeNewLine();
}
}
public function startTest(\PHPUnit_Framework_Test $test)
{
if ($test instanceof Test) {
parent::startTest($test);
}
}
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if ($test instanceof \PHPUnit_Framework_TestCase) {
$this->numAssertions += $test->getNumAssertions();
}
$this->lastTestFailed = false;
}
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->lastTestFailed = true;
}
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->lastTestFailed = true;
}
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->lastTestFailed = true;
}
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->lastTestFailed = true;
}
}