Skip to content

Commit 3830577

Browse files
alexpottnicolas-grekas
authored andcommitted
Use triggering file to determine weak vendors if when the test is run in a separate process
1 parent dd28a32 commit 3830577

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ public static function register($mode = 0)
121121
$msg = $parsedMsg['deprecation'];
122122
$class = $parsedMsg['class'];
123123
$method = $parsedMsg['method'];
124+
// If the deprecation has been triggered via
125+
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
126+
// then we need to use the serialized information to
127+
// determine if the error has been triggered from vendor
128+
// code.
129+
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($parsedMsg['triggering_file']));
124130
} else {
125131
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
126132
$method = $trace[$i]['function'];
@@ -261,7 +267,7 @@ public static function collectDeprecations($outputFile)
261267

262268
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
263269
}
264-
$deprecations[] = array(error_reporting(), $msg);
270+
$deprecations[] = array(error_reporting(), $msg, $file);
265271
});
266272

267273
register_shutdown_function(function () use ($outputFile, &$deprecations) {

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ public function endTest($test, $time)
272272
unlink($this->runsInSeparateProcess);
273273
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
274274
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
275+
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => $deprecation[2]));
275276
if ($deprecation[0]) {
276-
trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
277+
trigger_error($error, E_USER_DEPRECATED);
277278
} else {
278-
@trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
279+
@trigger_error($error, E_USER_DEPRECATED);
279280
}
280281
}
281282
$this->runsInSeparateProcess = false;

0 commit comments

Comments
 (0)