public function NodeImportCreateTest::testImportCreate in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Kernel/Config/NodeImportCreateTest.php \Drupal\Tests\node\Kernel\Config\NodeImportCreateTest::testImportCreate()
Tests creating a content type during config import.
File
- core/
modules/ node/ tests/ src/ Kernel/ Config/ NodeImportCreateTest.php, line 54
Class
- NodeImportCreateTest
- Create content types during config create method invocation.
Namespace
Drupal\Tests\node\Kernel\ConfigCode
public function testImportCreate() {
$node_type_id = 'import';
$node_type_config_name = "node.type.{$node_type_id}";
// Simulate config data to import.
$active = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
$this
->copyConfig($active, $sync);
// Manually add new node type.
$src_dir = __DIR__ . '/../../../modules/node_test_config/sync';
$target_dir = Settings::get('config_sync_directory');
$this
->assertNotFalse(\Drupal::service('file_system')
->copy("{$src_dir}/{$node_type_config_name}.yml", "{$target_dir}/{$node_type_config_name}.yml"));
// Import the content of the sync directory.
$this
->configImporter()
->import();
// Check that the content type was created.
$node_type = NodeType::load($node_type_id);
$this
->assertNotEmpty($node_type, 'Import node type from sync was created.');
$this
->assertNull(FieldConfig::loadByName('node', $node_type_id, 'body'));
}