function ConfigImportTest::testDeleted

Tests deletion of configuration during import.

File

drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php, line 59
Definition of Drupal\config\Tests\ConfigImportTest.

Class

ConfigImportTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\config\Tests

Code

function testDeleted() {
  $dynamic_name = 'config_test.dynamic.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'), 'default');

  // Create an empty manifest to delete the configuration object.
  $staging
    ->write('manifest.config_test.dynamic', array());

  // Import.
  config_import();

  // Verify the values have disappeared.
  $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(config_sync_get_changes($staging, $storage));
}