function ConfigImporterTest::testDeleted

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testDeleted()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testDeleted()
  3. 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testDeleted()

Tests deletion of configuration during import.

File

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

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testDeleted() {
    $dynamic_name = 'config_test.dynamic.dotted.default';
    $storage = $this->container
        ->get('config.storage');
    $sync = $this->container
        ->get('config.storage.sync');
    // Verify the default configuration values exist.
    $config = $this->config($dynamic_name);
    $this->assertIdentical($config->get('id'), 'dotted.default');
    // Delete the file from the sync directory.
    $sync->delete($dynamic_name);
    // Import.
    $this->configImporter
        ->reset()
        ->import();
    // Verify the file has been removed.
    $this->assertIdentical($storage->read($dynamic_name), FALSE);
    $config = $this->config($dynamic_name);
    $this->assertIdentical($config->get('id'), NULL);
    // Verify that appropriate module API hooks have been invoked.
    $this->assertTrue(isset($GLOBALS['hook_config_test']['load']));
    $this->assertFalse(isset($GLOBALS['hook_config_test']['presave']));
    $this->assertFalse(isset($GLOBALS['hook_config_test']['insert']));
    $this->assertFalse(isset($GLOBALS['hook_config_test']['update']));
    $this->assertTrue(isset($GLOBALS['hook_config_test']['predelete']));
    $this->assertTrue(isset($GLOBALS['hook_config_test']['delete']));
    $this->assertFalse($this->configImporter
        ->hasUnprocessedConfigurationChanges());
    $logs = $this->configImporter
        ->getErrors();
    $this->assertCount(0, $logs);
}

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