Issue #3052625 by Mile23, alexpott: DeprecationListenerTrait croaks on tests with no results
parent
6483dcdefb
commit
50a5f02e2e
|
@ -175,12 +175,16 @@ trait DeprecationListenerTrait {
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue