3 namespace Drupal\Tests\node\Kernel\Config;
5 use Drupal\node\Entity\NodeType;
6 use Drupal\KernelTests\KernelTestBase;
9 * Change content types during config create method invocation.
13 class NodeImportChangeTest extends KernelTestBase {
20 public static $modules = ['node', 'field', 'text', 'system', 'node_test_config', 'user'];
23 * Set the default field storage backend for fields created during tests.
25 protected function setUp() {
28 // Set default storage backend.
29 $this->installConfig(['system', 'field', 'node_test_config']);
33 * Tests importing an updated content type.
35 public function testImportChange() {
36 $node_type_id = 'default';
37 $node_type_config_name = "node.type.$node_type_id";
39 // Simulate config data to import:
40 // - a modified version (modified label) of the node type config.
41 $active = $this->container->get('config.storage');
42 $sync = $this->container->get('config.storage.sync');
43 $this->copyConfig($active, $sync);
45 $node_type = $active->read($node_type_config_name);
46 $new_label = 'Test update import field';
47 $node_type['name'] = $new_label;
48 // Save as files in the sync directory.
49 $sync->write($node_type_config_name, $node_type);
51 // Import the content of the sync directory.
52 $this->configImporter()->import();
54 // Check that the updated config was correctly imported.
55 $node_type = NodeType::load($node_type_id);
56 $this->assertEqual($node_type->label(), $new_label, 'Node type name has been updated.');