function ConfigImporterTest::testNew in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config/src/Tests/ConfigImporterTest.php \Drupal\config\Tests\ConfigImporterTest::testNew()
Tests creation of configuration during import.
File
- core/
modules/ config/ src/ Tests/ ConfigImporterTest.php, line 159 - Contains \Drupal\config\Tests\ConfigImporterTest.
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\config\TestsCode
function testNew() {
$dynamic_name = 'config_test.dynamic.new';
$storage = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
// Verify the configuration to create does not exist yet.
$this
->assertIdentical($storage
->exists($dynamic_name), FALSE, $dynamic_name . ' not found.');
// Create new config entity.
$original_dynamic_data = array(
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => \Drupal::languageManager()
->getDefaultLanguage()
->getId(),
'status' => TRUE,
'dependencies' => array(),
'id' => 'new',
'label' => 'New',
'weight' => 0,
'style' => '',
'size' => '',
'size_value' => '',
'protected_property' => '',
);
$sync
->write($dynamic_name, $original_dynamic_data);
$this
->assertIdentical($sync
->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
// Import.
$this->configImporter
->reset()
->import();
// Verify the values appeared.
$config = $this
->config($dynamic_name);
$this
->assertIdentical($config
->get('label'), $original_dynamic_data['label']);
// Verify that appropriate module API hooks have been invoked.
$this
->assertFalse(isset($GLOBALS['hook_config_test']['load']));
$this
->assertTrue(isset($GLOBALS['hook_config_test']['presave']));
$this
->assertTrue(isset($GLOBALS['hook_config_test']['insert']));
$this
->assertFalse(isset($GLOBALS['hook_config_test']['update']));
$this
->assertFalse(isset($GLOBALS['hook_config_test']['predelete']));
$this
->assertFalse(isset($GLOBALS['hook_config_test']['delete']));
// Verify that hook_config_import_steps_alter() can add steps to
// configuration synchronization.
$this
->assertTrue(isset($GLOBALS['hook_config_test']['config_import_steps_alter']));
// Verify that there is nothing more to import.
$this
->assertFalse($this->configImporter
->hasUnprocessedConfigurationChanges());
$logs = $this->configImporter
->getErrors();
$this
->assertEqual(count($logs), 0);
}