You are here

public function UpdateModeTest::testUpdateModePartialReset in Configuration Synchronizer 8.2

File

tests/src/Kernel/UpdateModeTest.php, line 207

Class

UpdateModeTest
Tests importing configuration entities using various import modes.

Namespace

Drupal\Tests\config_sync\Kernel

Code

public function testUpdateModePartialReset() {

  // Set update mode to partial reset.
  $this
    ->setUpdateMode(ConfigSyncListerInterface::UPDATE_MODE_PARTIAL_RESET);
  $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.
  $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('Provided name', $node_type_1
    ->label());
  $this
    ->assertEquals('Provided description', $node_type_1
    ->get('description'));
  $this
    ->assertEquals('Provided help', $node_type_1
    ->get('help'));
  $this
    ->verifySnapshot();
}