+
+ // In rare cases, when test data is serialized in the parent process, there
+ // is a service container but it doesn't contain all expected services. To
+ // avoid fatal errors during the wrap-up of failing tests, we check for this
+ // case, too.
+ if ($this->_entityStorages && (!$phpunit_bootstrap || $container->has('entity_type.manager'))) {
+ /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
+ $entity_type_manager = $container->get('entity_type.manager');
+ foreach ($this->_entityStorages as $key => $entity_type_id) {
+ $this->$key = $entity_type_manager->getStorage($entity_type_id);
+ }
+ }
+ $this->_entityStorages = [];