You are here

function ConfigImporterTest::testSecondaryDeletedDeleteeSecond in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigImporterTest.php \Drupal\config\Tests\ConfigImporterTest::testSecondaryDeletedDeleteeSecond()

Tests that secondary deletes for deleted files work as expected.

File

core/modules/config/src/Tests/ConfigImporterTest.php, line 437
Contains \Drupal\config\Tests\ConfigImporterTest.

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\config\Tests

Code

function testSecondaryDeletedDeleteeSecond() {
  $name_deleter = 'config_test.dynamic.deleter';
  $name_deletee = 'config_test.dynamic.deletee';
  $storage = $this->container
    ->get('config.storage');
  $uuid = $this->container
    ->get('uuid');
  $values_deleter = array(
    'id' => 'deleter',
    'label' => 'Deleter',
    'weight' => 0,
    'uuid' => $uuid
      ->generate(),
    // Add a dependency on deletee, to make sure this delete is synced first.
    'dependencies' => array(
      'config' => array(
        $name_deletee,
      ),
    ),
  );
  $storage
    ->write($name_deleter, $values_deleter);
  $values_deletee = array(
    'id' => 'deletee',
    'label' => 'Deletee',
    'weight' => 0,
    'uuid' => $uuid
      ->generate(),
  );
  $storage
    ->write($name_deletee, $values_deletee);

  // Import.
  $this->configImporter
    ->reset()
    ->import();
  $entity_storage = \Drupal::entityManager()
    ->getStorage('config_test');
  $this
    ->assertFalse($entity_storage
    ->load('deleter'));
  $this
    ->assertFalse($entity_storage
    ->load('deletee'));

  // The deletee entity does not exist as the delete worked and although the
  // delete occurred in \Drupal\config_test\Entity\ConfigTest::postDelete()
  // this does not matter.
  $logs = $this->configImporter
    ->getErrors();
  $this
    ->assertEqual(count($logs), 0);
}