function ContentEntityNullStorageTest::testDeleteThroughImport

Tests deleting an entity test no ID bundle entity via a configuration import.

See also

\Drupal\Core\Entity\Event\BundleConfigImportValidate

File

core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php, line 47

Class

ContentEntityNullStorageTest
Tests ContentEntityNullStorage entity query support.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testDeleteThroughImport() : void {
  $this->installConfig([
    'system',
  ]);
  $entity_test_no_id_bundle = EntityTestNoIdBundle::create([
    'id' => 'test',
    'label' => 'Test entity test no ID bundle',
  ]);
  $entity_test_no_id_bundle->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'));
  $config_importer = $this->container
    ->get(ConfigImporterFactory::class)
    ->get($storage_comparer->createChangelist());
  // Delete the entity test no ID bundle in sync.
  $sync = $this->container
    ->get('config.storage.sync');
  $sync->delete($entity_test_no_id_bundle->getConfigDependencyName());
  // Import.
  $config_importer->reset()
    ->import();
  $this->assertNull(EntityTestNoIdBundle::load($entity_test_no_id_bundle->id()), 'The entity test no ID bundle has been deleted.');
}

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