Use triggering file to determine weak vendors if when the test is run in a separate process

This commit is contained in:
Alex Pott 2018-01-04 16:17:31 +00:00 committed by Nicolas Grekas
parent dd28a3286f
commit 38305777f1
2 changed files with 10 additions and 3 deletions

View File

@ -121,6 +121,12 @@ class DeprecationErrorHandler
$msg = $parsedMsg['deprecation'];
$class = $parsedMsg['class'];
$method = $parsedMsg['method'];
// If the deprecation has been triggered via
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
// then we need to use the serialized information to
// determine if the error has been triggered from vendor
// code.
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($parsedMsg['triggering_file']));
} else {
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];
@ -261,7 +267,7 @@ class DeprecationErrorHandler
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
}
$deprecations[] = array(error_reporting(), $msg);
$deprecations[] = array(error_reporting(), $msg, $file);
});
register_shutdown_function(function () use ($outputFile, &$deprecations) {

View File

@ -272,10 +272,11 @@ class SymfonyTestsListenerTrait
unlink($this->runsInSeparateProcess);
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => $deprecation[2]));
if ($deprecation[0]) {
trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
trigger_error($error, E_USER_DEPRECATED);
} else {
@trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
@trigger_error($error, E_USER_DEPRECATED);
}
}
$this->runsInSeparateProcess = false;