diff --git a/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php b/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php index 5575c8c..26bc66b 100644 --- a/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php +++ b/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php @@ -68,6 +68,9 @@ protected function setUp() { /** * Tests the missing content event is fired. + * + * @see \Drupal\Core\Config\ConfigImporter::processMissingContent() + * @see \Drupal\config_import_test\EventSubscriber */ function testMissingContent() { \Drupal::state()->set('config_import_test.config_import_missing_content', TRUE); @@ -77,19 +80,28 @@ function testMissingContent() { $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); $entity_one = entity_create('entity_test', array('name' => 'one')); - $entity_two = entity_create('entity_test', array('name' => 'one')); + $entity_two = entity_create('entity_test', array('name' => 'two')); + $entity_three = entity_create('entity_test', array('name' => 'three')); $dynamic_name = 'config_test.dynamic.dotted.default'; $original_dynamic_data = $storage->read($dynamic_name); + // Entity one will be resolved by + // \Drupal\config_import_test\EventSubscriber::onConfigImporterMissingContentOne(). $original_dynamic_data['dependencies']['content'][] = $entity_one->getConfigDependencyName(); + // Entity two will be resolved by + // \Drupal\config_import_test\EventSubscriber::onConfigImporterMissingContentTwo(). $original_dynamic_data['dependencies']['content'][] = $entity_two->getConfigDependencyName(); + // Entity three will be resolved by + // \Drupal\Core\Config\Importer\FinalMissingContentSubscriber. + $original_dynamic_data['dependencies']['content'][] = $entity_three->getConfigDependencyName(); $staging->write($dynamic_name, $original_dynamic_data); // Import. $this->configImporter->reset()->import(); + $this->assertEqual([], $this->configImporter->getErrors(), 'There were no errors during the import.'); $this->assertEqual($entity_one->uuid(), \Drupal::state()->get('config_import_test.config_import_missing_content_one'), 'The missing content event is fired during configuration import.'); $this->assertEqual($entity_two->uuid(), \Drupal::state()->get('config_import_test.config_import_missing_content_two'), 'The missing content event is fired during configuration import.'); $original_dynamic_data = $storage->read($dynamic_name); - $this->assertEqual([$entity_one->getConfigDependencyName(), $entity_two->getConfigDependencyName()], $original_dynamic_data['dependencies']['content'], 'The imported configuration entity has the missing content entity dependency.'); + $this->assertEqual([$entity_one->getConfigDependencyName(), $entity_two->getConfigDependencyName(), $entity_three->getConfigDependencyName()], $original_dynamic_data['dependencies']['content'], 'The imported configuration entity has the missing content entity dependency.'); } } diff --git a/core/modules/config/tests/config_import_test/src/EventSubscriber.php b/core/modules/config/tests/config_import_test/src/EventSubscriber.php index 297e5f5..1a56829 100644 --- a/core/modules/config/tests/config_import_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_import_test/src/EventSubscriber.php @@ -77,7 +77,7 @@ public function onConfigImporterMissingContentOne(MissingContentEvent $event) { * The missing content event. */ public function onConfigImporterMissingContentTwo(MissingContentEvent $event) { - if ($this->state->get('config_import_test.config_import_missing_content', FALSE)) { + if ($this->state->get('config_import_test.config_import_missing_content', FALSE) && $this->state->get('config_import_test.config_import_missing_content_two', FALSE) === FALSE) { $missing = $event->getMissingContent(); $uuid = key($missing); $this->state->set('config_import_test.config_import_missing_content_two', key($missing));