function ConfigImporterTest::testSecondaryUpdateDeletedDeleterFirst in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config/src/Tests/ConfigImporterTest.php \Drupal\config\Tests\ConfigImporterTest::testSecondaryUpdateDeletedDeleterFirst()
Tests that secondary updates for deleted files work as expected.
File
- core/
modules/ config/ src/ Tests/ ConfigImporterTest.php, line 305 - Contains \Drupal\config\Tests\ConfigImporterTest.
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\config\TestsCode
function testSecondaryUpdateDeletedDeleterFirst() {
$name_deleter = 'config_test.dynamic.deleter';
$name_deletee = 'config_test.dynamic.deletee';
$name_other = 'config_test.dynamic.other';
$storage = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
$uuid = $this->container
->get('uuid');
$values_deleter = array(
'id' => 'deleter',
'label' => 'Deleter',
'weight' => 0,
'uuid' => $uuid
->generate(),
);
$storage
->write($name_deleter, $values_deleter);
$values_deleter['label'] = 'Updated Deleter';
$sync
->write($name_deleter, $values_deleter);
$values_deletee = array(
'id' => 'deletee',
'label' => 'Deletee',
'weight' => 0,
'uuid' => $uuid
->generate(),
// Add a dependency on deleter, to make sure that is synced first.
'dependencies' => array(
'config' => array(
$name_deleter,
),
),
);
$storage
->write($name_deletee, $values_deletee);
$values_deletee['label'] = 'Updated Deletee';
$sync
->write($name_deletee, $values_deletee);
// Ensure that import will continue after the error.
$values_other = array(
'id' => 'other',
'label' => 'Other',
'weight' => 0,
'uuid' => $uuid
->generate(),
// Add a dependency on deleter, to make sure that is synced first. This
// will also be synced after the deletee due to alphabetical ordering.
'dependencies' => array(
'config' => array(
$name_deleter,
),
),
);
$storage
->write($name_other, $values_other);
$values_other['label'] = 'Updated other';
$sync
->write($name_other, $values_other);
// Check update changelist order.
$updates = $this->configImporter
->reset()
->getStorageComparer()
->getChangelist('update');
$expected = array(
$name_deleter,
$name_deletee,
$name_other,
);
$this
->assertIdentical($expected, $updates);
// Import.
$this->configImporter
->import();
$entity_storage = \Drupal::entityManager()
->getStorage('config_test');
$deleter = $entity_storage
->load('deleter');
$this
->assertEqual($deleter
->id(), 'deleter');
$this
->assertEqual($deleter
->uuid(), $values_deleter['uuid']);
$this
->assertEqual($deleter
->label(), $values_deleter['label']);
// The deletee was deleted in
// \Drupal\config_test\Entity\ConfigTest::postSave().
$this
->assertFalse($entity_storage
->load('deletee'));
$other = $entity_storage
->load('other');
$this
->assertEqual($other
->id(), 'other');
$this
->assertEqual($other
->uuid(), $values_other['uuid']);
$this
->assertEqual($other
->label(), $values_other['label']);
$logs = $this->configImporter
->getErrors();
$this
->assertEqual(count($logs), 1);
$this
->assertEqual($logs[0], SafeMarkup::format('Update target "@name" is missing.', array(
'@name' => $name_deletee,
)));
}