8000 Merge branch '4.0' · symfony/symfony@d275178 · GitHub
[go: up one dir, main page]

Skip to content

Commit d275178

Browse files
Merge branch '4.0'
* 4.0: Use triggering file to determine weak vendors if when the test is run in a separate process
2 parents 34dd512 + 9624e44 commit d275178

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static function register($mode = 0)
107107

108108
$trace = debug_backtrace(true);
109109
$group = 'other';
110-
110+
$isVendor = false;
111111
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
112112

113113
$i = count($trace);
@@ -121,6 +121,11 @@ 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 determine
127+
// if the error has been triggered from vendor code.
128+
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($parsedMsg['triggering_file']));
124129
} else {
125130
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
126131
$method = $trace[$i]['function'];
@@ -261,7 +266,7 @@ public static function collectDeprecations($outputFile)
261266

262267
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
263268
}
264-
$deprecations[] = array(error_reporting(), $msg);
269+
$deprecations[] = array(error_reporting(), $msg, $file);
265270
});
266271

267272
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
@@ -263,10 +263,11 @@ public function endTest($test, $time)
263263
unlink($this->runsInSeparateProcess);
264264
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
265265
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
266+
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => $deprecation[2]));
266267
if ($deprecation[0]) {
267-
trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
268+
trigger_error($error, E_USER_DEPRECATED);
268269
} else {
269-
@trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);
270+
@trigger_error($error, E_USER_DEPRECATED);
270271
}
271272
}
272273
$this->runsInSeparateProcess = false;

0 commit comments

Comments
 (0)
0