function PhptTestCase::getLocationHintFromDiff
1 call to PhptTestCase::getLocationHintFromDiff()
- PhptTestCase::run in vendor/
phpunit/ phpunit/ src/ Runner/ PhptTestCase.php - Runs a test and collects its result in a TestResult instance.
File
-
vendor/
phpunit/ phpunit/ src/ Runner/ PhptTestCase.php, line 695
Class
- PhptTestCase
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\RunnerCode
private function getLocationHintFromDiff(string $message, array $sections) : array {
$needle = '';
$previousLine = '';
$block = 'message';
foreach (preg_split('/\\r\\n|\\r|\\n/', $message) as $line) {
$line = trim($line);
if ($block === 'message' && $line === '--- Expected') {
$block = 'expected';
}
if ($block === 'expected' && $line === '@@ @@') {
$block = 'diff';
}
if ($block === 'diff') {
if (str_starts_with($line, '+')) {
$needle = $this->getCleanDiffLine($previousLine);
break;
}
if (str_starts_with($line, '-')) {
$needle = $this->getCleanDiffLine($line);
break;
}
}
if (!empty($line)) {
$previousLine = $line;
}
}
return $this->getLocationHint($needle, $sections);
}