-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStormPrinter.php
More file actions
38 lines (33 loc) · 1.31 KB
/
StormPrinter.php
File metadata and controls
38 lines (33 loc) · 1.31 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
<?php
namespace Ozh\PHPUnit\Printer;
use PHPUnit\TextUI\DefaultResultPrinter;
use PHPUnit\Framework\TestFailure;
use PHPUnit\Util\Filter;
class StormPrinter extends DefaultResultPrinter
{
protected function printDefectTrace(TestFailure $defect): void
{
$this->write(($defect->getExceptionAsString()));
$trace = Filter::getFilteredStacktrace(
$defect->thrownException()
);
if (!empty($trace)) {
// From: D:\home\planetozh\ozh.in\tests\tests\install\install.php:14
// To: storm --line 14 /d/home/planetozh/ozh.in/tests/tests/install/install.php
$trace = str_replace('\\', '/', $trace);
// replace 'DRIVE:/' with '/drive/'
$trace = preg_replace_callback('/^([A-Z]+):/', function ($re) {return '/'.strtolower($re[1]);}, $trace);
list($file, $line) = explode(':', trim($trace));
$this->write("\nstorm --line $line $file \n");
}
$exception = $defect->thrownException()->getPrevious();
while ($exception) {
$this->write(
"\nCaused by\n" .
TestFailure::exceptionToString($exception) . "\n" .
Filter::getFilteredStacktrace($exception)
);
$exception = $exception->getPrevious();
}
}
}