function ConfigImporterTest::testDeleted

Tests deletion of configuration during import.

File

drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php, line 100
Contains \Drupal\config\Tests\ConfigImporterTest.

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\config\Tests

Code

function testDeleted() {
  $dynamic_name = 'config_test.dynamic.dotted.default';
  $storage = $this->container
    ->get('config.storage');
  $staging = $this->container
    ->get('config.storage.staging');

  // Verify the default configuration values exist.
  $config = config($dynamic_name);
  $this
    ->assertIdentical($config
    ->get('id'), 'dotted.default');

  // Delete the file from the staging directory.
  $staging
    ->delete($dynamic_name);

  // Import.
  $this->configImporter
    ->reset()
    ->import();

  // Verify the file has been removed.
  $this
    ->assertIdentical($storage
    ->read($dynamic_name), FALSE);
  $config = 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']));

  // Verify that there is nothing more to import.
  $this
    ->assertFalse($this->configImporter
    ->hasUnprocessedChanges());
}