mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-33075 find correct location of failed test case classes
This commit is contained in:
parent
4f7f2a8828
commit
f32ecd2fbe
1 changed files with 20 additions and 8 deletions
|
@ -44,16 +44,28 @@ class Hint_ResultPrinter extends PHPUnit_TextUI_ResultPrinter {
|
|||
|
||||
$exception = $defect->thrownException();
|
||||
$trace = $exception->getTrace();
|
||||
$file = null;
|
||||
|
||||
if (class_exists('ReflectionClass')) {
|
||||
$reflection = new ReflectionClass($testName);
|
||||
$file = $reflection->getFileName();
|
||||
|
||||
} else {
|
||||
$file = false;
|
||||
$dirroot = realpath($CFG->dirroot).DIRECTORY_SEPARATOR;
|
||||
$classpath = realpath("$CFG->dirroot/lib/phpunit/classes").DIRECTORY_SEPARATOR;
|
||||
foreach ($trace as $item) {
|
||||
if (strpos($item['file'], $dirroot) === 0 and strpos($item['file'], $classpath) !== 0) {
|
||||
if ($content = file_get_contents($item['file'])) {
|
||||
if (preg_match('/class\s+'.$testName.'\s+extends/', $content)) {
|
||||
$file = $item['file'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($file === null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($file === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue