Update TestKernel.php

This commit is contained in:
Gonzalo Vilaseca 2015-12-14 17:47:23 +00:00
parent e45127d88b
commit 69fd3b1418

View file

@ -18,6 +18,7 @@ class TestKernel extends Kernel
if (!in_array($this->environment, ['test', 'test_cached'])) {
parent::shutdown();
return;
}
@ -42,15 +43,21 @@ class TestKernel extends Kernel
}
$serviceObject = new \ReflectionObject($service);
foreach ($serviceObject->getProperties() as $prop) {
$prop->setAccessible(true);
if ($prop->isStatic()) {
continue;
}
$prop->setValue($service, null);
$properties = $serviceObject->getProperties();
// If it has a static property it could be a singleton, therefore we should not
// reset it's properties
foreach ($properties as $property) {
if ($property->isStatic()) {
continue 2;
}
}
foreach ($properties as $property) {
$property->setAccessible(true);
$property->setValue($service, null);
}
}
$property->setValue($container, null);
}
}
}