You are here

public function ContentEntityNullStorageTest::testDeleteThroughImport in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php \Drupal\system\Tests\Entity\ContentEntityNullStorageTest::testDeleteThroughImport()

Tests deleting a contact form entity via a configuration import.

See also

\Drupal\Core\Entity\Event\BundleConfigImportValidate

File

core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php, line 50
Contains \Drupal\system\Tests\Entity\ContentEntityNullStorageTest.

Class

ContentEntityNullStorageTest
Tests ContentEntityNullStorage entity query support.

Namespace

Drupal\system\Tests\Entity

Code

public function testDeleteThroughImport() {
  $contact_form = ContactForm::create([
    'id' => 'test',
  ]);
  $contact_form
    ->save();
  $this
    ->copyConfig($this->container
    ->get('config.storage'), $this->container
    ->get('config.storage.sync'));

  // Set up the ConfigImporter object for testing.
  $storage_comparer = new StorageComparer($this->container
    ->get('config.storage.sync'), $this->container
    ->get('config.storage'), $this->container
    ->get('config.manager'));
  $config_importer = new ConfigImporter($storage_comparer
    ->createChangelist(), $this->container
    ->get('event_dispatcher'), $this->container
    ->get('config.manager'), $this->container
    ->get('lock'), $this->container
    ->get('config.typed'), $this->container
    ->get('module_handler'), $this->container
    ->get('module_installer'), $this->container
    ->get('theme_handler'), $this->container
    ->get('string_translation'));

  // Delete the contact message in sync.
  $sync = $this->container
    ->get('config.storage.sync');
  $sync
    ->delete($contact_form
    ->getConfigDependencyName());

  // Import.
  $config_importer
    ->reset()
    ->import();
  $this
    ->assertNull(ContactForm::load($contact_form
    ->id()), 'The contact form has been deleted.');
}