Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / node / tests / src / Kernel / Config / NodeImportChangeTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Kernel\Config;
4
5 use Drupal\node\Entity\NodeType;
6 use Drupal\KernelTests\KernelTestBase;
7
8 /**
9  * Change content types during config create method invocation.
10  *
11  * @group node
12  */
13 class NodeImportChangeTest extends KernelTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['node', 'field', 'text', 'system', 'node_test_config', 'user'];
21
22   /**
23    * Set the default field storage backend for fields created during tests.
24    */
25   protected function setUp() {
26     parent::setUp();
27
28     // Set default storage backend.
29     $this->installConfig(['system', 'field', 'node_test_config']);
30   }
31
32   /**
33    * Tests importing an updated content type.
34    */
35   public function testImportChange() {
36     $node_type_id = 'default';
37     $node_type_config_name = "node.type.$node_type_id";
38
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);
44
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);
50
51     // Import the content of the sync directory.
52     $this->configImporter()->import();
53
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.');
57   }
58
59 }