public function UpdateModeTest::testUpdateModeMerge in Configuration Synchronizer 8.2
File
- tests/
src/ Kernel/ UpdateModeTest.php, line 172
Class
- UpdateModeTest
- Tests importing configuration entities using various import modes.
Namespace
Drupal\Tests\config_sync\KernelCode
public function testUpdateModeMerge() {
// Set update mode to merge.
$this
->setUpdateMode(ConfigSyncListerInterface::UPDATE_MODE_MERGE);
$creates = $this->configImporter
->getUnprocessedConfiguration('create');
$updates = $this->configImporter
->getUnprocessedConfiguration('update');
$this
->assertEquals(0, count($this->configImporter
->getUnprocessedConfiguration('delete')), 'There are no configuration items to delete.');
// node.type.config_sync_test_2 was deleted from both the snapshot and
// the active configuration and so should be created.
// node.type.config_sync_test_3 was deleted from active but should not be
// restored since it is snapshotted.
$expected_creates = [
$this->configNames[2],
];
$this
->assertSame($creates, $expected_creates, 'Create operations match those expected.');
// For node.type.config_sync_test_1, the snapshot differs from the current
// provided value and not all of the differences are customized in the
// active configuration.
$expected_updates = [
$this->configNames[1],
];
$this
->assertSame($updates, $expected_updates, 'Update operations match those expected.');
$this->configImporter
->import();
$this->container
->get('event_dispatcher')
->dispatch(ConfigDistroEvents::IMPORT);
// Verify that the expected config changes were made.
$node_type_1 = NodeType::load($this->nodeTypeNames[1]);
$this
->assertEquals('Custom name', $node_type_1
->label());
$this
->assertEquals('Provided description', $node_type_1
->get('description'));
$this
->assertEquals('Custom help', $node_type_1
->get('help'));
$this
->verifySnapshot();
}