function ConfigImporterTest::testSecondaryWriteSecondaryFirst in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config/src/Tests/ConfigImporterTest.php \Drupal\config\Tests\ConfigImporterTest::testSecondaryWriteSecondaryFirst()
Tests that secondary writes are overwritten.
File
- core/
modules/ config/ src/ Tests/ ConfigImporterTest.php, line 259 - Contains \Drupal\config\Tests\ConfigImporterTest.
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\config\TestsCode
function testSecondaryWriteSecondaryFirst() {
$name_primary = 'config_test.dynamic.primary';
$name_secondary = 'config_test.dynamic.secondary';
$sync = $this->container
->get('config.storage.sync');
$uuid = $this->container
->get('uuid');
$values_primary = array(
'id' => 'primary',
'label' => 'Primary',
'weight' => 0,
'uuid' => $uuid
->generate(),
// Add a dependency on secondary, so that is synced first.
'dependencies' => array(
'config' => array(
$name_secondary,
),
),
);
$sync
->write($name_primary, $values_primary);
$values_secondary = array(
'id' => 'secondary',
'label' => 'Secondary Sync',
'weight' => 0,
'uuid' => $uuid
->generate(),
);
$sync
->write($name_secondary, $values_secondary);
// Import.
$this->configImporter
->reset()
->import();
$entity_storage = \Drupal::entityManager()
->getStorage('config_test');
$primary = $entity_storage
->load('primary');
$this
->assertEqual($primary
->id(), 'primary');
$this
->assertEqual($primary
->uuid(), $values_primary['uuid']);
$this
->assertEqual($primary
->label(), $values_primary['label']);
$secondary = $entity_storage
->load('secondary');
$this
->assertEqual($secondary
->id(), 'secondary');
$this
->assertEqual($secondary
->uuid(), $values_secondary['uuid']);
$this
->assertEqual($secondary
->label(), $values_secondary['label']);
$logs = $this->configImporter
->getErrors();
$this
->assertEqual(count($logs), 1);
$this
->assertEqual($logs[0], Html::escape("Unexpected error during import with operation create for {$name_primary}: 'config_test' entity with ID 'secondary' already exists."));
}