NodeImportChangeTest.php in Drupal 10
File
core/modules/node/tests/src/Kernel/Config/NodeImportChangeTest.php
View source
<?php
namespace Drupal\Tests\node\Kernel\Config;
use Drupal\node\Entity\NodeType;
use Drupal\KernelTests\KernelTestBase;
class NodeImportChangeTest extends KernelTestBase {
protected static $modules = [
'node',
'field',
'text',
'system',
'node_test_config',
'user',
];
protected function setUp() : void {
parent::setUp();
$this
->installConfig([
'system',
'field',
'node_test_config',
]);
}
public function testImportChange() {
$node_type_id = 'default';
$node_type_config_name = "node.type.{$node_type_id}";
$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;
$sync
->write($node_type_config_name, $node_type);
$this
->configImporter()
->import();
$node_type = NodeType::load($node_type_id);
$this
->assertEquals($new_label, $node_type
->label(), 'Node type name has been updated.');
}
}