Skip to content
Snippets Groups Projects
Commit 50a5f02e authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3052625 by Mile23, alexpott: DeprecationListenerTrait croaks on tests with no results

parent 6483dcde
No related branches found
No related tags found
No related merge requests found
......@@ -175,12 +175,16 @@ protected function registerErrorHandler($test) {
// SymfonyTestsListenerTrait has its own error handler that needs to be
// removed before this one.
$test_result_object = $test->getTestResultObject();
$reflection_class = new \ReflectionClass($test_result_object);
$reflection_property = $reflection_class->getProperty('listeners');
$reflection_property->setAccessible(TRUE);
$listeners = $reflection_property->getValue($test_result_object);
$listeners[] = new AfterSymfonyListener();
$reflection_property->setValue($test_result_object, $listeners);
// It's possible that a test does not have a result object. This can happen
// when a test class does not have any test methods.
if ($test_result_object) {
$reflection_class = new \ReflectionClass($test_result_object);
$reflection_property = $reflection_class->getProperty('listeners');
$reflection_property->setAccessible(TRUE);
$listeners = $reflection_property->getValue($test_result_object);
$listeners[] = new AfterSymfonyListener();
$reflection_property->setValue($test_result_object, $listeners);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment