You are here

public function NodeImportChangeTest::testImportChange in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/Config/NodeImportChangeTest.php \Drupal\node\Tests\Config\NodeImportChangeTest::testImportChange()

Tests importing an updated content type.

File

core/modules/node/src/Tests/Config/NodeImportChangeTest.php, line 40
Contains \Drupal\node\Tests\Config\NodeImportChangeTest.

Class

NodeImportChangeTest
Change content types during config create method invocation.

Namespace

Drupal\node\Tests\Config

Code

public function testImportChange() {
  $node_type_id = 'default';
  $node_type_config_name = "node.type.{$node_type_id}";

  // Simulate config data to import:
  // - a modified version (modified label) of the node type config.
  $active = $this->container
    ->get('config.storage');
  $sync = $this->container
    ->get('config.storage.sync');
  $this
    ->copyConfig($active, $sync);
  $node_type = $active
    ->read($node_type_config_name);
  $new_label = 'Test update import field';
  $node_type['name'] = $new_label;

  // Save as files in the sync directory.
  $sync
    ->write($node_type_config_name, $node_type);

  // Import the content of the sync directory.
  $this
    ->configImporter()
    ->import();

  // Check that the updated config was correctly imported.
  $node_type = NodeType::load($node_type_id);
  $this
    ->assertEqual($node_type
    ->label(), $new_label, 'Node type name has been updated.');
}