function ConfigImporterTest::testSecondaryDeletedChildSecond

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testSecondaryDeletedChildSecond()

Tests that secondary deletes for deleted files work as expected.

File

core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php, line 424

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testSecondaryDeletedChildSecond() : void {
    $name_dependency = 'config_test.dynamic.dependency';
    $name_dependent = 'config_test.dynamic.dependent';
    $storage = $this->container
        ->get('config.storage');
    $uuid = $this->container
        ->get('uuid');
    $values_dependency = [
        'id' => 'dependency',
        'label' => 'Dependency',
        'weight' => 0,
        'uuid' => $uuid->generate(),
        // Add a dependency on dependent, to make sure this delete is synced first.
'dependencies' => [
            'config' => [
                $name_dependent,
            ],
        ],
    ];
    $storage->write($name_dependency, $values_dependency);
    $values_dependent = [
        'id' => 'dependent',
        'label' => 'Dependent',
        'weight' => 0,
        'uuid' => $uuid->generate(),
    ];
    $storage->write($name_dependent, $values_dependent);
    // Import.
    $config_importer = $this->configImporter();
    $config_importer->import();
    $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test');
    $this->assertNull($entity_storage->load('dependency'));
    $this->assertNull($entity_storage->load('dependent'));
    // The dependent entity does not exist as the delete worked and although the
    // delete occurred in \Drupal\config_test\Entity\ConfigTest::postDelete()
    // this does not matter.
    $logs = $config_importer->getErrors();
    $this->assertCount(0, $logs);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.