Tests importing configuration.
function testImport() {
$name = 'system.site';
$dynamic_name = 'config_test.dynamic.new';
$storage = $this->container
->get('config.storage');
$staging = $this->container
->get('config.storage.staging');
// Verify the configuration to create and update does not exist yet.
$this
->assertIdentical($staging
->exists($name), FALSE, $name . ' not found.');
$this
->assertIdentical($staging
->exists($dynamic_name), FALSE, $dynamic_name . ' not found.');
// Verify that the import UI recognises that the staging folder is empty.
$this
->drupalGet('admin/config/development/sync');
$this
->assertText('There is no configuration to import.');
// Create updated configuration object.
$new_site_name = 'Config import test ' . $this
->randomString();
$this
->prepareSiteNameUpdate($new_site_name);
$this
->assertIdentical($staging
->exists($name), TRUE, $name . ' found.');
// Create new config entity.
$original_dynamic_data = array(
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
'style' => '',
'langcode' => 'und',
);
$staging
->write($dynamic_name, $original_dynamic_data);
// Create manifest for new config entity.
$manifest_data = config('manifest.config_test.dynamic')
->get();
$manifest_data[$original_dynamic_data['id']]['name'] = 'config_test.dynamic.' . $original_dynamic_data['id'];
$staging
->write('manifest.config_test.dynamic', $manifest_data);
$this
->assertIdentical($staging
->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
// Verify that both appear as new.
$this
->drupalGet('admin/config/development/sync');
$this
->assertText($name);
$this
->assertText($dynamic_name);
// Import and verify that both do not appear anymore.
$this
->drupalPost(NULL, array(), t('Import all'));
$this
->assertUrl('admin/config/development/sync');
$this
->assertNoText($name);
$this
->assertNoText($dynamic_name);
// Verify that there are no further changes to import.
$this
->assertText(t('There is no configuration to import.'));
// Verify site name has changed.
$this
->assertIdentical($new_site_name, config('system.site')
->get('name'));
// Verify that new config entity exists.
$this
->assertIdentical($original_dynamic_data, config($dynamic_name)
->get());
// Verify the cache got cleared.
$this
->assertTrue(isset($GLOBALS['hook_cache_flush']));
}