Issue #2487588 by YesCT, Leksat, Schnitzel, alexpott, anavarre, xjm: Move CMI import/export directory "staging" to "sync", as it is confused with staging environments
parent
09990f5741
commit
bfb117c569
|
@ -115,7 +115,7 @@
|
|||
* and HAL.
|
||||
* - Node entity support is configured by default. If you would like to support
|
||||
* other types of entities, you can copy
|
||||
* core/modules/rest/config/install/rest.settings.yml to your staging
|
||||
* core/modules/rest/config/install/rest.settings.yml to your sync
|
||||
* configuration directory, appropriately modified for other entity types,
|
||||
* and import it. Support for GET on the log from the Database Logging module
|
||||
* can also be enabled in this way; in this case, the 'entity:node' line
|
||||
|
|
|
@ -290,9 +290,13 @@ services:
|
|||
public: false
|
||||
tags:
|
||||
- { name: backend_overridable }
|
||||
# @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use
|
||||
# config.storage.sync instead.
|
||||
config.storage.staging:
|
||||
class: Drupal\Core\Config\FileStorage
|
||||
factory: Drupal\Core\Config\FileStorageFactory::getStaging
|
||||
factory: Drupal\Core\Config\FileStorageFactory::getSync
|
||||
config.storage.sync:
|
||||
alias: config.storage.staging
|
||||
config.storage.snapshot:
|
||||
class: Drupal\Core\Config\DatabaseStorage
|
||||
arguments: ['@database', config_snapshot]
|
||||
|
|
|
@ -108,10 +108,21 @@ const DRUPAL_PHP_FUNCTION_PATTERN = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
|
|||
*/
|
||||
const CONFIG_ACTIVE_DIRECTORY = 'active';
|
||||
|
||||
/**
|
||||
* $config_directories key for sync directory.
|
||||
*
|
||||
* @see config_get_config_directory()
|
||||
*/
|
||||
const CONFIG_SYNC_DIRECTORY = 'sync';
|
||||
|
||||
/**
|
||||
* $config_directories key for staging directory.
|
||||
*
|
||||
* @see config_get_config_directory()
|
||||
* @see CONFIG_SYNC_DIRECTORY
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x and will be removed before 9.0.0. The staging
|
||||
* directory was renamed to sync.
|
||||
*/
|
||||
const CONFIG_STAGING_DIRECTORY = 'staging';
|
||||
|
||||
|
@ -130,7 +141,7 @@ define('DRUPAL_ROOT', dirname(dirname(__DIR__)));
|
|||
*
|
||||
* @param string $type
|
||||
* The type of config directory to return. Drupal core provides the
|
||||
* CONFIG_STAGING_DIRECTORY constant to access the staging directory.
|
||||
* CONFIG_SYNC_DIRECTORY constant to access the sync directory.
|
||||
*
|
||||
* @return string
|
||||
* The configuration directory path.
|
||||
|
@ -140,6 +151,11 @@ define('DRUPAL_ROOT', dirname(dirname(__DIR__)));
|
|||
function config_get_config_directory($type) {
|
||||
global $config_directories;
|
||||
|
||||
// @todo Remove fallback in Drupal 9. https://www.drupal.org/node/2574943
|
||||
if ($type == CONFIG_SYNC_DIRECTORY && !isset($config_directories[CONFIG_SYNC_DIRECTORY]) && isset($config_directories[CONFIG_STAGING_DIRECTORY])) {
|
||||
$type = CONFIG_STAGING_DIRECTORY;
|
||||
}
|
||||
|
||||
if (!empty($config_directories[$type])) {
|
||||
return $config_directories[$type];
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ function file_ensure_htaccess() {
|
|||
file_save_htaccess('private://', TRUE);
|
||||
}
|
||||
file_save_htaccess('temporary://', TRUE);
|
||||
file_save_htaccess(config_get_config_directory(CONFIG_STAGING_DIRECTORY), TRUE);
|
||||
file_save_htaccess(config_get_config_directory(CONFIG_SYNC_DIRECTORY), TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -362,7 +362,7 @@ function install_begin_request($class_loader, &$install_state) {
|
|||
\Drupal::setContainer($container);
|
||||
|
||||
// Determine whether base system services are ready to operate.
|
||||
$install_state['config_verified'] = install_ensure_config_directory(CONFIG_STAGING_DIRECTORY);
|
||||
$install_state['config_verified'] = install_ensure_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
$install_state['database_verified'] = install_verify_database_settings($site_path);
|
||||
$install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'];
|
||||
|
||||
|
|
|
@ -202,8 +202,8 @@ function drupal_get_database_types() {
|
|||
* and comment properties.
|
||||
* @code
|
||||
* $settings['config_directories'] = array(
|
||||
* CONFIG_STAGING_DIRECTORY => (object) array(
|
||||
* 'value' => 'config_hash/staging',
|
||||
* CONFIG_SYNC_DIRECTORY => (object) array(
|
||||
* 'value' => 'config_hash/sync',
|
||||
* 'required' => TRUE,
|
||||
* ),
|
||||
* );
|
||||
|
@ -211,7 +211,7 @@ function drupal_get_database_types() {
|
|||
* gets dumped as:
|
||||
* @code
|
||||
* $config_directories['active'] = 'config_hash/active';
|
||||
* $config_directories['staging'] = 'config_hash/staging'
|
||||
* $config_directories['sync'] = 'config_hash/sync'
|
||||
* @endcode
|
||||
*/
|
||||
function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
|
||||
|
@ -487,9 +487,9 @@ function drupal_install_config_directories() {
|
|||
// manually defined in the existing already.
|
||||
$settings = [];
|
||||
$config_directories_hash = Crypt::randomBytesBase64(55);
|
||||
if (empty($config_directories[CONFIG_STAGING_DIRECTORY])) {
|
||||
$settings['config_directories'][CONFIG_STAGING_DIRECTORY] = (object) [
|
||||
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/staging',
|
||||
if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
|
||||
$settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
|
||||
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/sync',
|
||||
'required' => TRUE,
|
||||
];
|
||||
}
|
||||
|
@ -505,19 +505,19 @@ function drupal_install_config_directories() {
|
|||
// public files directory, which has already been verified to be writable
|
||||
// itself. But if it somehow fails anyway, the installation cannot proceed.
|
||||
// Bail out using a similar error message as in system_requirements().
|
||||
if (!install_ensure_config_directory(CONFIG_STAGING_DIRECTORY)) {
|
||||
if (!install_ensure_config_directory(CONFIG_SYNC_DIRECTORY)) {
|
||||
throw new Exception(t('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', array(
|
||||
'%directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY),
|
||||
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
|
||||
':handbook_url' => 'https://www.drupal.org/server-permissions',
|
||||
)));
|
||||
}
|
||||
|
||||
// Put a README.txt into the staging config directory. This is required so
|
||||
// that they can later be added to git. Since this directory is auto-
|
||||
// created, we have to write out the README rather than just adding it
|
||||
// to the drupal core repo.
|
||||
// Put a README.txt into the sync config directory. This is required so that
|
||||
// they can later be added to git. Since this directory is auto-created, we
|
||||
// have to write out the README rather than just adding it to the drupal core
|
||||
// repo.
|
||||
$text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' .' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
|
||||
file_put_contents(config_get_config_directory(CONFIG_STAGING_DIRECTORY) . '/README.txt', $text);
|
||||
file_put_contents(config_get_config_directory(CONFIG_SYNC_DIRECTORY) . '/README.txt', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -525,7 +525,7 @@ function drupal_install_config_directories() {
|
|||
*
|
||||
* @param string $type
|
||||
* Type of config directory to return. Drupal core provides 'active' and
|
||||
* 'staging'.
|
||||
* 'sync'.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the config directory exists and is writable.
|
||||
|
|
|
@ -367,8 +367,8 @@ class ConfigImporter {
|
|||
$current_extensions = $this->storageComparer->getTargetStorage()->read('core.extension');
|
||||
$new_extensions = $this->storageComparer->getSourceStorage()->read('core.extension');
|
||||
|
||||
// If there is no extension information in staging then exit. This is
|
||||
// probably due to an empty staging directory.
|
||||
// If there is no extension information in sync then exit. This is probably
|
||||
// due to an empty sync directory.
|
||||
if (!$new_extensions) {
|
||||
return;
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ class ConfigImporter {
|
|||
* The name of the extension to process.
|
||||
*/
|
||||
protected function processExtension($type, $op, $name) {
|
||||
// Set the config installer to use the staging directory instead of the
|
||||
// Set the config installer to use the sync directory instead of the
|
||||
// extensions own default config directories.
|
||||
\Drupal::service('config.installer')
|
||||
->setSyncing(TRUE)
|
||||
|
|
|
@ -85,9 +85,9 @@ use Drupal\Component\Utility\SortArray;
|
|||
* configuration object so that they can be checked without the module that
|
||||
* provides the configuration entity class being installed. This is important
|
||||
* for configuration synchronization, which needs to be able to validate
|
||||
* configuration in the staging directory before the synchronization has
|
||||
* occurred. Also, if you have a configuration entity object and you want to
|
||||
* get the current dependencies (without recalculation), you can use
|
||||
* configuration in the sync directory before the synchronization has occurred.
|
||||
* Also, if you have a configuration entity object and you want to get the
|
||||
* current dependencies (without recalculation), you can use
|
||||
* \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies().
|
||||
*
|
||||
* When uninstalling a module or a theme, configuration entities that are
|
||||
|
|
|
@ -25,12 +25,12 @@ class FileStorageFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a FileStorage object working with the staging config directory.
|
||||
* Returns a FileStorage object working with the sync config directory.
|
||||
*
|
||||
* @return \Drupal\Core\Config\FileStorage FileStorage
|
||||
*/
|
||||
static function getStaging() {
|
||||
return new FileStorage(config_get_config_directory(CONFIG_STAGING_DIRECTORY));
|
||||
static function getSync() {
|
||||
return new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ function config_help($route_name, RouteMatchInterface $route_match) {
|
|||
|
||||
case 'config.sync':
|
||||
$output = '';
|
||||
$output .= '<p>' . t('Compare the configuration uploaded to your staging directory with the active configuration before completing the import.') . '</p>';
|
||||
$output .= '<p>' . t('Compare the configuration uploaded to your sync directory with the active configuration before completing the import.') . '</p>';
|
||||
return $output;
|
||||
|
||||
case 'config.export_full':
|
||||
|
@ -43,7 +43,7 @@ function config_help($route_name, RouteMatchInterface $route_match) {
|
|||
|
||||
case 'config.import_full':
|
||||
$output = '';
|
||||
$output .= '<p>' . t('Upload a full site configuration archive to the staging directory. It can then be compared and imported on the Synchronize page.') . '</p>';
|
||||
$output .= '<p>' . t('Upload a full site configuration archive to the sync directory. It can then be compared and imported on the Synchronize page.') . '</p>';
|
||||
return $output;
|
||||
|
||||
case 'config.export_single':
|
||||
|
|
|
@ -64,7 +64,7 @@ class ConfigController implements ContainerInjectionInterface {
|
|||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config.storage'),
|
||||
$container->get('config.storage.staging'),
|
||||
$container->get('config.storage.sync'),
|
||||
$container->get('config.manager'),
|
||||
new FileDownloadController(),
|
||||
$container->get('diff.formatter')
|
||||
|
|
|
@ -40,7 +40,7 @@ class ConfigImportForm extends FormBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config.storage.staging')
|
||||
$container->get('config.storage.sync')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ class ConfigImportForm extends FormBase {
|
|||
foreach ($archiver->listContent() as $file) {
|
||||
$files[] = $file['filename'];
|
||||
}
|
||||
$archiver->extractList($files, config_get_config_directory(CONFIG_STAGING_DIRECTORY));
|
||||
$archiver->extractList($files, config_get_config_directory(CONFIG_SYNC_DIRECTORY));
|
||||
drupal_set_message($this->t('Your configuration files were successfully uploaded and are ready for import.'));
|
||||
$form_state->setRedirect('config.sync');
|
||||
}
|
||||
|
|
|
@ -39,11 +39,11 @@ class ConfigSync extends FormBase {
|
|||
protected $lock;
|
||||
|
||||
/**
|
||||
* The staging configuration object.
|
||||
* The sync configuration object.
|
||||
*
|
||||
* @var \Drupal\Core\Config\StorageInterface
|
||||
*/
|
||||
protected $stagingStorage;
|
||||
protected $syncStorage;
|
||||
|
||||
/**
|
||||
* The active configuration object.
|
||||
|
@ -111,7 +111,7 @@ class ConfigSync extends FormBase {
|
|||
/**
|
||||
* Constructs the object.
|
||||
*
|
||||
* @param \Drupal\Core\Config\StorageInterface $staging_storage
|
||||
* @param \Drupal\Core\Config\StorageInterface $sync_storage
|
||||
* The source storage.
|
||||
* @param \Drupal\Core\Config\StorageInterface $active_storage
|
||||
* The target storage.
|
||||
|
@ -134,8 +134,8 @@ class ConfigSync extends FormBase {
|
|||
* @param \Drupal\Core\Render\RendererInterface
|
||||
* The renderer.
|
||||
*/
|
||||
public function __construct(StorageInterface $staging_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, RendererInterface $renderer) {
|
||||
$this->stagingStorage = $staging_storage;
|
||||
public function __construct(StorageInterface $sync_storage, StorageInterface $active_storage, StorageInterface $snapshot_storage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, TypedConfigManagerInterface $typed_config, ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, ThemeHandlerInterface $theme_handler, RendererInterface $renderer) {
|
||||
$this->syncStorage = $sync_storage;
|
||||
$this->activeStorage = $active_storage;
|
||||
$this->snapshotStorage = $snapshot_storage;
|
||||
$this->lock = $lock;
|
||||
|
@ -153,7 +153,7 @@ class ConfigSync extends FormBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config.storage.staging'),
|
||||
$container->get('config.storage.sync'),
|
||||
$container->get('config.storage'),
|
||||
$container->get('config.storage.snapshot'),
|
||||
$container->get('lock.persistent'),
|
||||
|
@ -183,8 +183,8 @@ class ConfigSync extends FormBase {
|
|||
'#type' => 'submit',
|
||||
'#value' => $this->t('Import all'),
|
||||
);
|
||||
$source_list = $this->stagingStorage->listAll();
|
||||
$storage_comparer = new StorageComparer($this->stagingStorage, $this->activeStorage, $this->configManager);
|
||||
$source_list = $this->syncStorage->listAll();
|
||||
$storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, $this->configManager);
|
||||
if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) {
|
||||
$form['no_changes'] = array(
|
||||
'#type' => 'table',
|
||||
|
|
|
@ -28,8 +28,8 @@ trait AssertConfigEntityImportTrait {
|
|||
$entity_uuid = $entity->uuid();
|
||||
$entity_type_id = $entity->getEntityTypeId();
|
||||
$original_data = $entity->toArray();
|
||||
// Copy everything to staging.
|
||||
$this->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.staging'));
|
||||
// Copy everything to sync.
|
||||
$this->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.sync'));
|
||||
// Delete the configuration from active. Don't worry about side effects of
|
||||
// deleting config like fields cleaning up field storages. The coming import
|
||||
// should recreate everything as necessary.
|
||||
|
|
|
@ -28,7 +28,7 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
*/
|
||||
function testDiff() {
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$config_name = 'config_test.system';
|
||||
$change_key = 'foo';
|
||||
$remove_key = '404';
|
||||
|
@ -43,44 +43,44 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
// Install the default config.
|
||||
$this->installConfig(array('config_test'));
|
||||
|
||||
// Change a configuration value in staging.
|
||||
$staging_data = $original_data;
|
||||
$staging_data[$change_key] = $change_data;
|
||||
$staging_data[$add_key] = $add_data;
|
||||
$staging->write($config_name, $staging_data);
|
||||
// Change a configuration value in sync.
|
||||
$sync_data = $original_data;
|
||||
$sync_data[$change_key] = $change_data;
|
||||
$sync_data[$add_key] = $add_data;
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Verify that the diff reflects a change.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name);
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'change', 'The first item in the diff is a change.');
|
||||
$this->assertEqual($edits[0]->orig[0], $change_key . ': ' . $original_data[$change_key], format_string("The active value for key '%change_key' is '%original_data'.", array('%change_key' => $change_key, '%original_data' => $original_data[$change_key])));
|
||||
$this->assertEqual($edits[0]->closing[0], $change_key . ': ' . $change_data, format_string("The staging value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data)));
|
||||
$this->assertEqual($edits[0]->closing[0], $change_key . ': ' . $change_data, format_string("The sync value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data)));
|
||||
|
||||
// Reset data back to original, and remove a key
|
||||
$staging_data = $original_data;
|
||||
unset($staging_data[$remove_key]);
|
||||
$staging->write($config_name, $staging_data);
|
||||
$sync_data = $original_data;
|
||||
unset($sync_data[$remove_key]);
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Verify that the diff reflects a removed key.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name);
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[1]->type, 'delete', 'The second item in the diff is a delete.');
|
||||
$this->assertEqual($edits[1]->orig[0], $remove_key . ': ' . $original_data[$remove_key], format_string("The active value for key '%remove_key' is '%original_data'.", array('%remove_key' => $remove_key, '%original_data' => $original_data[$remove_key])));
|
||||
$this->assertFalse($edits[1]->closing, format_string("The key '%remove_key' does not exist in staging.", array('%remove_key' => $remove_key)));
|
||||
$this->assertFalse($edits[1]->closing, format_string("The key '%remove_key' does not exist in sync.", array('%remove_key' => $remove_key)));
|
||||
|
||||
// Reset data back to original and add a key
|
||||
$staging_data = $original_data;
|
||||
$staging_data[$add_key] = $add_data;
|
||||
$staging->write($config_name, $staging_data);
|
||||
$sync_data = $original_data;
|
||||
$sync_data[$add_key] = $add_data;
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Verify that the diff reflects an added key.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name);
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[1]->type, 'add', 'The second item in the diff is an add.');
|
||||
$this->assertFalse($edits[1]->orig, format_string("The key '%add_key' does not exist in active.", array('%add_key' => $add_key)));
|
||||
$this->assertEqual($edits[1]->closing[0], $add_key . ': ' . $add_data, format_string("The staging value for key '%add_key' is '%add_data'.", array('%add_key' => $add_key, '%add_data' => $add_data)));
|
||||
$this->assertEqual($edits[1]->closing[0], $add_key . ': ' . $add_data, format_string("The sync value for key '%add_key' is '%add_data'.", array('%add_key' => $add_key, '%add_data' => $add_data)));
|
||||
|
||||
// Test diffing a renamed config entity.
|
||||
$test_entity_id = $this->randomMachineName();
|
||||
|
@ -90,9 +90,9 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
));
|
||||
$test_entity->save();
|
||||
$data = $active->read('config_test.dynamic.' . $test_entity_id);
|
||||
$staging->write('config_test.dynamic.' . $test_entity_id, $data);
|
||||
$sync->write('config_test.dynamic.' . $test_entity_id, $data);
|
||||
$config_name = 'config_test.dynamic.' . $test_entity_id;
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name, $config_name);
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, $config_name);
|
||||
// Prove the fields match.
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
|
@ -103,7 +103,7 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
$test_entity->set('id', $new_test_entity_id);
|
||||
$test_entity->save();
|
||||
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, 'config_test.dynamic.' . $new_test_entity_id, $config_name);
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, 'config_test.dynamic.' . $new_test_entity_id, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual($edits[1]->type, 'change', 'The second item in the diff is a change.');
|
||||
|
@ -119,27 +119,27 @@ class ConfigDiffTest extends KernelTestBase {
|
|||
function testCollectionDiff() {
|
||||
/** @var \Drupal\Core\Config\StorageInterface $active */
|
||||
$active = $this->container->get('config.storage');
|
||||
/** @var \Drupal\Core\Config\StorageInterface $staging */
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
/** @var \Drupal\Core\Config\StorageInterface $sync */
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$active_test_collection = $active->createCollection('test');
|
||||
$staging_test_collection = $staging->createCollection('test');
|
||||
$sync_test_collection = $sync->createCollection('test');
|
||||
|
||||
$config_name = 'config_test.test';
|
||||
$data = array('foo' => 'bar');
|
||||
|
||||
$active->write($config_name, $data);
|
||||
$staging->write($config_name, $data);
|
||||
$sync->write($config_name, $data);
|
||||
$active_test_collection->write($config_name, $data);
|
||||
$staging_test_collection->write($config_name, array('foo' => 'baz'));
|
||||
$sync_test_collection->write($config_name, array('foo' => 'baz'));
|
||||
|
||||
// Test the fields match in the default collection diff.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name);
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name);
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'copy', 'The first item in the diff is a copy.');
|
||||
$this->assertEqual(count($edits), 1, 'There is one item in the diff');
|
||||
|
||||
// Test that the differences are detected when diffing the collection.
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name, NULL, 'test');
|
||||
$diff = \Drupal::service('config.manager')->diff($active, $sync, $config_name, NULL, 'test');
|
||||
$edits = $diff->getEdits();
|
||||
$this->assertEqual($edits[0]->type, 'change', 'The second item in the diff is a copy.');
|
||||
$this->assertEqual($edits[0]->orig, array('foo: bar'));
|
||||
|
|
|
@ -11,7 +11,7 @@ use Drupal\simpletest\KernelTestBase;
|
|||
use Drupal\Core\Config\ConfigDuplicateUUIDException;
|
||||
|
||||
/**
|
||||
* Tests staging and importing config entities with IDs and UUIDs that match
|
||||
* Tests sync and importing config entities with IDs and UUIDs that match
|
||||
* existing config.
|
||||
*
|
||||
* @group config
|
||||
|
|
|
@ -191,21 +191,21 @@ class ConfigExportImportUITest extends WebTestBase {
|
|||
// Ensure the item is displayed as part of a list (to avoid false matches
|
||||
// on the rest of the page) and that the list markup is not escaped.
|
||||
$this->assertRaw('<li>system.site</li>');
|
||||
// Remove everything from staging. The warning about differences between the
|
||||
// Remove everything from sync. The warning about differences between the
|
||||
// active and snapshot should no longer exist.
|
||||
\Drupal::service('config.storage.staging')->deleteAll();
|
||||
\Drupal::service('config.storage.sync')->deleteAll();
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
$this->assertNoText(t('Warning message'));
|
||||
$this->assertNoText('The following items in your active configuration have changes since the last import that may be lost on the next import.');
|
||||
$this->assertText(t('There are no configuration changes to import.'));
|
||||
// Write a file to staging. The warning about differences between the
|
||||
// active and snapshot should now exist.
|
||||
/** @var \Drupal\Core\Config\StorageInterface $staging */
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
// Write a file to sync. The warning about differences between the active
|
||||
// and snapshot should now exist.
|
||||
/** @var \Drupal\Core\Config\StorageInterface $sync */
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$data = $this->config('system.site')->get();
|
||||
$data['slogan'] = 'in the face';
|
||||
$this->copyConfig($this->container->get('config.storage'), $staging);
|
||||
$staging->write('system.site', $data);
|
||||
$this->copyConfig($this->container->get('config.storage'), $sync);
|
||||
$sync->write('system.site', $data);
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
$this->assertText(t('Warning message'));
|
||||
$this->assertText('The following items in your active configuration have changes since the last import that may be lost on the next import.');
|
||||
|
|
|
@ -210,7 +210,7 @@ class ConfigFileContentTest extends KernelTestBase {
|
|||
);
|
||||
|
||||
// Encode and write, and reload and decode the configuration data.
|
||||
$filestorage = new FileStorage($this->configDirectories[CONFIG_STAGING_DIRECTORY]);
|
||||
$filestorage = new FileStorage($this->configDirectories[CONFIG_SYNC_DIRECTORY]);
|
||||
$filestorage->write($name, $config_data);
|
||||
$config_parsed = $filestorage->read($name);
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ class ConfigImportAllTest extends ModuleTestBase {
|
|||
$this->assertModuleTablesExist($module);
|
||||
}
|
||||
|
||||
// Export active config to staging
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
// Export active config to sync.
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
system_list_reset();
|
||||
$this->resetAll();
|
||||
|
@ -145,7 +145,7 @@ class ConfigImportAllTest extends ModuleTestBase {
|
|||
|
||||
// Ensure that we have no configuration changes to import.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
|
|
@ -42,7 +42,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
|
|||
|
||||
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
|
||||
$this->drupalLogin($this->webUser);
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,13 +51,13 @@ class ConfigImportInstallProfileTest extends WebTestBase {
|
|||
* @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber
|
||||
*/
|
||||
public function testInstallProfileValidation() {
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($this->container->get('config.storage'), $staging);
|
||||
$core = $staging->read('core.extension');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($this->container->get('config.storage'), $sync);
|
||||
$core = $sync->read('core.extension');
|
||||
|
||||
// Ensure install profiles can not be uninstalled.
|
||||
unset($core['module']['testing_config_import']);
|
||||
$staging->write('core.extension', $core);
|
||||
$sync->write('core.extension', $core);
|
||||
|
||||
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
|
||||
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
|
||||
|
@ -68,11 +68,11 @@ class ConfigImportInstallProfileTest extends WebTestBase {
|
|||
unset($core['module']['syslog']);
|
||||
unset($core['theme']['stark']);
|
||||
$core['theme']['classy'] = 0;
|
||||
$staging->write('core.extension', $core);
|
||||
$staging->deleteAll('syslog.');
|
||||
$theme = $staging->read('system.theme');
|
||||
$sync->write('core.extension', $core);
|
||||
$sync->deleteAll('syslog.');
|
||||
$theme = $sync->read('system.theme');
|
||||
$theme['default'] = 'classy';
|
||||
$staging->write('system.theme', $theme);
|
||||
$sync->write('system.theme', $theme);
|
||||
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
|
||||
$this->assertText('The configuration was imported successfully.');
|
||||
$this->rebuildContainer();
|
||||
|
|
|
@ -40,11 +40,11 @@ class ConfigImportRecreateTest extends KernelTestBase {
|
|||
$this->installEntitySchema('node');
|
||||
$this->installConfig(array('field', 'node'));
|
||||
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -71,11 +71,11 @@ class ConfigImportRecreateTest extends KernelTestBase {
|
|||
node_add_body_field($content_type);
|
||||
/** @var \Drupal\Core\Config\StorageInterface $active */
|
||||
$active = $this->container->get('config.storage');
|
||||
/** @var \Drupal\Core\Config\StorageInterface $staging */
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
/** @var \Drupal\Core\Config\StorageInterface $sync */
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
$config_name = $content_type->getEntityType()->getConfigPrefix() . '.' . $content_type->id();
|
||||
$this->copyConfig($active, $staging);
|
||||
$this->copyConfig($active, $sync);
|
||||
|
||||
// Delete the content type. This will also delete a field storage, a field,
|
||||
// an entity view display and an entity form display.
|
||||
|
|
|
@ -48,7 +48,7 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
|
|||
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -80,8 +80,8 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
|
|||
|
||||
// Stage the test entity and then delete it from the active storage.
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
$test_entity->delete();
|
||||
|
||||
// Create a content type with a matching UUID in the active storage.
|
||||
|
@ -127,8 +127,8 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
|
|||
$config->set('uuid', $uuid_value)->save();
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
$config->delete();
|
||||
|
||||
// Create another simple configuration with the same UUID.
|
||||
|
|
|
@ -38,7 +38,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
|
||||
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
|
||||
$this->drupalLogin($this->webUser);
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,8 +47,8 @@ class ConfigImportUITest extends WebTestBase {
|
|||
function testImport() {
|
||||
$name = 'system.site';
|
||||
$dynamic_name = 'config_test.dynamic.new';
|
||||
/** @var \Drupal\Core\Config\StorageInterface $staging */
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
/** @var \Drupal\Core\Config\StorageInterface $sync */
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
$this->assertText('There are no configuration changes to import.');
|
||||
|
@ -57,7 +57,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
// 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.');
|
||||
$this->assertIdentical($sync->exists($name), TRUE, $name . ' found.');
|
||||
|
||||
// Create new config entity.
|
||||
$original_dynamic_data = array(
|
||||
|
@ -73,8 +73,8 @@ class ConfigImportUITest extends WebTestBase {
|
|||
'size_value' => '',
|
||||
'protected_property' => '',
|
||||
);
|
||||
$staging->write($dynamic_name, $original_dynamic_data);
|
||||
$this->assertIdentical($staging->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
|
||||
$sync->write($dynamic_name, $original_dynamic_data);
|
||||
$this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
|
||||
|
||||
// Enable the Action and Ban modules during import. The Ban
|
||||
// module is used because it creates a table during the install. The Action
|
||||
|
@ -87,7 +87,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
// Bartik is a subtheme of classy so classy must be enabled.
|
||||
$core_extension['theme']['classy'] = 0;
|
||||
$core_extension['theme']['bartik'] = 0;
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$sync->write('core.extension', $core_extension);
|
||||
|
||||
// Use the install storage so that we can read configuration from modules
|
||||
// and themes that are not installed.
|
||||
|
@ -96,17 +96,17 @@ class ConfigImportUITest extends WebTestBase {
|
|||
// Set the Bartik theme as default.
|
||||
$system_theme = $this->config('system.theme')->get();
|
||||
$system_theme['default'] = 'bartik';
|
||||
$staging->write('system.theme', $system_theme);
|
||||
$sync->write('system.theme', $system_theme);
|
||||
|
||||
// Read the action config from module default config folder.
|
||||
$action_settings = $install_storage->read('action.settings');
|
||||
$action_settings['recursion_limit'] = 50;
|
||||
$staging->write('action.settings', $action_settings);
|
||||
$sync->write('action.settings', $action_settings);
|
||||
|
||||
// Uninstall the Options and Text modules to ensure that dependencies are
|
||||
// handled correctly. Options depends on Text so Text should be installed
|
||||
// first. Since they were enabled during the test setup the core.extension
|
||||
// file in staging will already contain them.
|
||||
// file in sync will already contain them.
|
||||
\Drupal::service('module_installer')->uninstall(array('text', 'options'));
|
||||
|
||||
// Set the state system to record installations and uninstallations.
|
||||
|
@ -175,14 +175,14 @@ class ConfigImportUITest extends WebTestBase {
|
|||
unset($core_extension['module']['options']);
|
||||
unset($core_extension['module']['text']);
|
||||
unset($core_extension['theme']['bartik']);
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$staging->delete('action.settings');
|
||||
$staging->delete('text.settings');
|
||||
$sync->write('core.extension', $core_extension);
|
||||
$sync->delete('action.settings');
|
||||
$sync->delete('text.settings');
|
||||
|
||||
$system_theme = $this->config('system.theme')->get();
|
||||
$system_theme['default'] = 'stark';
|
||||
$system_theme['admin'] = 'stark';
|
||||
$staging->write('system.theme', $system_theme);
|
||||
$sync->write('system.theme', $system_theme);
|
||||
|
||||
// Set the state system to record installations and uninstallations.
|
||||
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array());
|
||||
|
@ -254,12 +254,12 @@ class ConfigImportUITest extends WebTestBase {
|
|||
* Tests verification of site UUID before importing configuration.
|
||||
*/
|
||||
function testImportSiteUuidValidation() {
|
||||
$staging = \Drupal::service('config.storage.staging');
|
||||
$sync = \Drupal::service('config.storage.sync');
|
||||
// Create updated configuration object.
|
||||
$config_data = $this->config('system.site')->get();
|
||||
// Generate a new site UUID.
|
||||
$config_data['uuid'] = \Drupal::service('uuid')->generate();
|
||||
$staging->write('system.site', $config_data);
|
||||
$sync->write('system.site', $config_data);
|
||||
|
||||
// Verify that there are configuration differences to import.
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
|
@ -268,10 +268,10 @@ class ConfigImportUITest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests the screen that shows differences between active and staging.
|
||||
* Tests the screen that shows differences between active and sync.
|
||||
*/
|
||||
function testImportDiff() {
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$config_name = 'config_test.system';
|
||||
$change_key = 'foo';
|
||||
$remove_key = '404';
|
||||
|
@ -286,12 +286,12 @@ class ConfigImportUITest extends WebTestBase {
|
|||
// Update active storage to have html in config data.
|
||||
$this->config($config_name)->setData($original_data)->save();
|
||||
|
||||
// Change a configuration value in staging.
|
||||
$staging_data = $original_data;
|
||||
$staging_data[$change_key] = $change_data;
|
||||
$staging_data[$add_key] = $add_data;
|
||||
unset($staging_data[$remove_key]);
|
||||
$staging->write($config_name, $staging_data);
|
||||
// Change a configuration value in sync.
|
||||
$sync_data = $original_data;
|
||||
$sync_data[$change_key] = $change_data;
|
||||
$sync_data[$add_key] = $add_data;
|
||||
unset($sync_data[$remove_key]);
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Load the diff UI and verify that the diff reflects the change.
|
||||
$this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
|
||||
|
@ -312,9 +312,9 @@ class ConfigImportUITest extends WebTestBase {
|
|||
$this->assertText(Html::escape("404: '<em>herp</em>'"));
|
||||
|
||||
// Reset data back to original, and remove a key
|
||||
$staging_data = $original_data;
|
||||
unset($staging_data[$remove_key]);
|
||||
$staging->write($config_name, $staging_data);
|
||||
$sync_data = $original_data;
|
||||
unset($sync_data[$remove_key]);
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Load the diff UI and verify that the diff reflects a removed key.
|
||||
$this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
|
||||
|
@ -325,9 +325,9 @@ class ConfigImportUITest extends WebTestBase {
|
|||
$this->assertText(Html::escape("404: '<em>herp</em>'"));
|
||||
|
||||
// Reset data back to original and add a key
|
||||
$staging_data = $original_data;
|
||||
$staging_data[$add_key] = $add_data;
|
||||
$staging->write($config_name, $staging_data);
|
||||
$sync_data = $original_data;
|
||||
$sync_data[$add_key] = $add_data;
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Load the diff UI and verify that the diff reflects an added key.
|
||||
$this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
|
||||
|
@ -364,11 +364,11 @@ class ConfigImportUITest extends WebTestBase {
|
|||
}
|
||||
|
||||
public function testConfigUninstallConfigException() {
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
$core_extension = $this->config('core.extension')->get();
|
||||
unset($core_extension['module']['config']);
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$sync->write('core.extension', $core_extension);
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
$this->assertText('core.extension');
|
||||
|
@ -379,11 +379,11 @@ class ConfigImportUITest extends WebTestBase {
|
|||
}
|
||||
|
||||
function prepareSiteNameUpdate($new_site_name) {
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
// Create updated configuration object.
|
||||
$config_data = $this->config('system.site')->get();
|
||||
$config_data['name'] = $new_site_name;
|
||||
$staging->write('system.site', $config_data);
|
||||
$sync->write('system.site', $config_data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,7 +392,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
function testImportErrorLog() {
|
||||
$name_primary = 'config_test.dynamic.primary';
|
||||
$name_secondary = 'config_test.dynamic.secondary';
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$uuid = $this->container->get('uuid');
|
||||
|
||||
$values_primary = array(
|
||||
|
@ -408,7 +408,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
'size_value' => NULL,
|
||||
'protected_property' => NULL,
|
||||
);
|
||||
$staging->write($name_primary, $values_primary);
|
||||
$sync->write($name_primary, $values_primary);
|
||||
$values_secondary = array(
|
||||
'uuid' => $uuid->generate(),
|
||||
'langcode' => 'en',
|
||||
|
@ -425,7 +425,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
'size_value' => NULL,
|
||||
'protected_property' => NULL,
|
||||
);
|
||||
$staging->write($name_secondary, $values_secondary);
|
||||
$sync->write($name_secondary, $values_secondary);
|
||||
// Verify that there are configuration differences to import.
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
$this->assertNoText(t('There are no configuration changes to import.'));
|
||||
|
@ -445,7 +445,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
*/
|
||||
public function testEntityBundleDelete() {
|
||||
\Drupal::service('module_installer')->install(array('node'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
$node_type = $this->drupalCreateContentType();
|
||||
$node = $this->drupalCreateNode(array('type' => $node_type->id()));
|
||||
|
@ -492,9 +492,9 @@ class ConfigImportUITest extends WebTestBase {
|
|||
\Drupal::service('theme_handler')->install(['bartik']);
|
||||
$this->rebuildContainer();
|
||||
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($this->container->get('config.storage'), $staging);
|
||||
$core = $staging->read('core.extension');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($this->container->get('config.storage'), $sync);
|
||||
$core = $sync->read('core.extension');
|
||||
// Node depends on text.
|
||||
unset($core['module']['text']);
|
||||
$module_data = system_rebuild_module_data();
|
||||
|
@ -507,7 +507,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
$core['module']['does_not_exist'] = 0;
|
||||
// This theme does not exist.
|
||||
$core['theme']['does_not_exist'] = 0;
|
||||
$staging->write('core.extension', $core);
|
||||
$sync->write('core.extension', $core);
|
||||
|
||||
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
|
||||
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
|
||||
|
|
|
@ -45,11 +45,11 @@ class ConfigImporterMissingContentTest extends KernelTestBase {
|
|||
// so it has to be cleared out manually.
|
||||
unset($GLOBALS['hook_config_test']);
|
||||
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -75,10 +75,10 @@ class ConfigImporterMissingContentTest extends KernelTestBase {
|
|||
function testMissingContent() {
|
||||
\Drupal::state()->set('config_import_test.config_import_missing_content', TRUE);
|
||||
|
||||
// Update a configuration entity in the staging directory to have a
|
||||
// dependency on two content entities that do not exist.
|
||||
// Update a configuration entity in the sync directory to have a dependency
|
||||
// on two content entities that do not exist.
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$entity_one = entity_create('entity_test', array('name' => 'one'));
|
||||
$entity_two = entity_create('entity_test', array('name' => 'two'));
|
||||
$entity_three = entity_create('entity_test', array('name' => 'three'));
|
||||
|
@ -93,7 +93,7 @@ class ConfigImporterMissingContentTest extends KernelTestBase {
|
|||
// Entity three will be resolved by
|
||||
// \Drupal\Core\Config\Importer\FinalMissingContentSubscriber.
|
||||
$original_dynamic_data['dependencies']['content'][] = $entity_three->getConfigDependencyName();
|
||||
$staging->write($dynamic_name, $original_dynamic_data);
|
||||
$sync->write($dynamic_name, $original_dynamic_data);
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
|
|
@ -44,11 +44,11 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
// so it has to be cleared out manually.
|
||||
unset($GLOBALS['hook_config_test']);
|
||||
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -80,12 +80,12 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that trying to import from an empty staging configuration directory
|
||||
* Tests that trying to import from an empty sync configuration directory
|
||||
* fails.
|
||||
*/
|
||||
function testEmptyImportFails() {
|
||||
try {
|
||||
$this->container->get('config.storage.staging')->deleteAll();
|
||||
$this->container->get('config.storage.sync')->deleteAll();
|
||||
$this->configImporter->reset()->import();
|
||||
$this->fail('ConfigImporterException thrown, successfully stopping an empty import.');
|
||||
}
|
||||
|
@ -98,12 +98,12 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
* Tests verification of site UUID before importing configuration.
|
||||
*/
|
||||
function testSiteUuidValidate() {
|
||||
$staging = \Drupal::service('config.storage.staging');
|
||||
$sync = \Drupal::service('config.storage.sync');
|
||||
// Create updated configuration object.
|
||||
$config_data = $this->config('system.site')->get();
|
||||
// Generate a new site UUID.
|
||||
$config_data['uuid'] = \Drupal::service('uuid')->generate();
|
||||
$staging->write('system.site', $config_data);
|
||||
$sync->write('system.site', $config_data);
|
||||
try {
|
||||
$this->configImporter->reset()->import();
|
||||
$this->fail('ConfigImporterException not thrown, invalid import was not stopped due to mis-matching site UUID.');
|
||||
|
@ -122,14 +122,14 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
function testDeleted() {
|
||||
$dynamic_name = 'config_test.dynamic.dotted.default';
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
// Verify the default configuration values exist.
|
||||
$config = $this->config($dynamic_name);
|
||||
$this->assertIdentical($config->get('id'), 'dotted.default');
|
||||
|
||||
// Delete the file from the staging directory.
|
||||
$staging->delete($dynamic_name);
|
||||
// Delete the file from the sync directory.
|
||||
$sync->delete($dynamic_name);
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
@ -159,7 +159,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
function testNew() {
|
||||
$dynamic_name = 'config_test.dynamic.new';
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$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.');
|
||||
|
@ -178,9 +178,9 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
'size_value' => '',
|
||||
'protected_property' => '',
|
||||
);
|
||||
$staging->write($dynamic_name, $original_dynamic_data);
|
||||
$sync->write($dynamic_name, $original_dynamic_data);
|
||||
|
||||
$this->assertIdentical($staging->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
|
||||
$this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
@ -213,7 +213,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
function testSecondaryWritePrimaryFirst() {
|
||||
$name_primary = 'config_test.dynamic.primary';
|
||||
$name_secondary = 'config_test.dynamic.secondary';
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$uuid = $this->container->get('uuid');
|
||||
|
||||
$values_primary = array(
|
||||
|
@ -222,7 +222,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
'weight' => 0,
|
||||
'uuid' => $uuid->generate(),
|
||||
);
|
||||
$staging->write($name_primary, $values_primary);
|
||||
$sync->write($name_primary, $values_primary);
|
||||
$values_secondary = array(
|
||||
'id' => 'secondary',
|
||||
'label' => 'Secondary Sync',
|
||||
|
@ -233,7 +233,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
'config' => array($name_primary),
|
||||
)
|
||||
);
|
||||
$staging->write($name_secondary, $values_secondary);
|
||||
$sync->write($name_secondary, $values_secondary);
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
@ -259,7 +259,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
function testSecondaryWriteSecondaryFirst() {
|
||||
$name_primary = 'config_test.dynamic.primary';
|
||||
$name_secondary = 'config_test.dynamic.secondary';
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$uuid = $this->container->get('uuid');
|
||||
|
||||
$values_primary = array(
|
||||
|
@ -272,14 +272,14 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
'config' => array($name_secondary),
|
||||
)
|
||||
);
|
||||
$staging->write($name_primary, $values_primary);
|
||||
$sync->write($name_primary, $values_primary);
|
||||
$values_secondary = array(
|
||||
'id' => 'secondary',
|
||||
'label' => 'Secondary Sync',
|
||||
'weight' => 0,
|
||||
'uuid' => $uuid->generate(),
|
||||
);
|
||||
$staging->write($name_secondary, $values_secondary);
|
||||
$sync->write($name_secondary, $values_secondary);
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
@ -307,7 +307,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
$name_deletee = 'config_test.dynamic.deletee';
|
||||
$name_other = 'config_test.dynamic.other';
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$uuid = $this->container->get('uuid');
|
||||
|
||||
$values_deleter = array(
|
||||
|
@ -318,7 +318,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
);
|
||||
$storage->write($name_deleter, $values_deleter);
|
||||
$values_deleter['label'] = 'Updated Deleter';
|
||||
$staging->write($name_deleter, $values_deleter);
|
||||
$sync->write($name_deleter, $values_deleter);
|
||||
$values_deletee = array(
|
||||
'id' => 'deletee',
|
||||
'label' => 'Deletee',
|
||||
|
@ -331,7 +331,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
);
|
||||
$storage->write($name_deletee, $values_deletee);
|
||||
$values_deletee['label'] = 'Updated Deletee';
|
||||
$staging->write($name_deletee, $values_deletee);
|
||||
$sync->write($name_deletee, $values_deletee);
|
||||
|
||||
// Ensure that import will continue after the error.
|
||||
$values_other = array(
|
||||
|
@ -347,7 +347,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
);
|
||||
$storage->write($name_other, $values_other);
|
||||
$values_other['label'] = 'Updated other';
|
||||
$staging->write($name_other, $values_other);
|
||||
$sync->write($name_other, $values_other);
|
||||
|
||||
// Check update changelist order.
|
||||
$updates = $this->configImporter->reset()->getStorageComparer()->getChangelist('update');
|
||||
|
@ -392,7 +392,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
$name_deleter = 'config_test.dynamic.deleter';
|
||||
$name_deletee = 'config_test.dynamic.deletee';
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$uuid = $this->container->get('uuid');
|
||||
|
||||
$values_deleter = array(
|
||||
|
@ -407,7 +407,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
);
|
||||
$storage->write($name_deleter, $values_deleter);
|
||||
$values_deleter['label'] = 'Updated Deleter';
|
||||
$staging->write($name_deleter, $values_deleter);
|
||||
$sync->write($name_deleter, $values_deleter);
|
||||
$values_deletee = array(
|
||||
'id' => 'deletee',
|
||||
'label' => 'Deletee',
|
||||
|
@ -416,7 +416,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
);
|
||||
$storage->write($name_deletee, $values_deletee);
|
||||
$values_deletee['label'] = 'Updated Deletee';
|
||||
$staging->write($name_deletee, $values_deletee);
|
||||
$sync->write($name_deletee, $values_deletee);
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
@ -480,21 +480,21 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
$name = 'config_test.system';
|
||||
$dynamic_name = 'config_test.dynamic.dotted.default';
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
// Verify that the configuration objects to import exist.
|
||||
$this->assertIdentical($storage->exists($name), TRUE, $name . ' found.');
|
||||
$this->assertIdentical($storage->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
|
||||
|
||||
// Replace the file content of the existing configuration objects in the
|
||||
// staging directory.
|
||||
// sync directory.
|
||||
$original_name_data = array(
|
||||
'foo' => 'beer',
|
||||
);
|
||||
$staging->write($name, $original_name_data);
|
||||
$sync->write($name, $original_name_data);
|
||||
$original_dynamic_data = $storage->read($dynamic_name);
|
||||
$original_dynamic_data['label'] = 'Updated';
|
||||
$staging->write($dynamic_name, $original_dynamic_data);
|
||||
$sync->write($dynamic_name, $original_dynamic_data);
|
||||
|
||||
// Verify the active configuration still returns the default values.
|
||||
$config = $this->config($name);
|
||||
|
@ -513,8 +513,8 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
$this->assertIdentical($config->get('label'), 'Updated');
|
||||
|
||||
// Verify that the original file content is still the same.
|
||||
$this->assertIdentical($staging->read($name), $original_name_data);
|
||||
$this->assertIdentical($staging->read($dynamic_name), $original_dynamic_data);
|
||||
$this->assertIdentical($sync->read($name), $original_name_data);
|
||||
$this->assertIdentical($sync->read($dynamic_name), $original_dynamic_data);
|
||||
|
||||
// Verify that appropriate module API hooks have been invoked.
|
||||
$this->assertTrue(isset($GLOBALS['hook_config_test']['load']));
|
||||
|
@ -549,29 +549,29 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
*/
|
||||
public function testUnmetDependency() {
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
// Test an unknown configuration owner.
|
||||
$staging->write('unknown.config', ['test' => 'test']);
|
||||
$sync->write('unknown.config', ['test' => 'test']);
|
||||
|
||||
// Make a config entity have unmet dependencies.
|
||||
$config_entity_data = $staging->read('config_test.dynamic.dotted.default');
|
||||
$config_entity_data = $sync->read('config_test.dynamic.dotted.default');
|
||||
$config_entity_data['dependencies'] = ['module' => ['unknown']];
|
||||
$staging->write('config_test.dynamic.dotted.module', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.module', $config_entity_data);
|
||||
$config_entity_data['dependencies'] = ['theme' => ['unknown']];
|
||||
$staging->write('config_test.dynamic.dotted.theme', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.theme', $config_entity_data);
|
||||
$config_entity_data['dependencies'] = ['config' => ['unknown']];
|
||||
$staging->write('config_test.dynamic.dotted.config', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.config', $config_entity_data);
|
||||
|
||||
// Make an active config depend on something that is missing in staging.
|
||||
// Make an active config depend on something that is missing in sync.
|
||||
// The whole configuration needs to be consistent, not only the updated one.
|
||||
$config_entity_data['dependencies'] = [];
|
||||
$storage->write('config_test.dynamic.dotted.deleted', $config_entity_data);
|
||||
$config_entity_data['dependencies'] = ['config' => ['config_test.dynamic.dotted.deleted']];
|
||||
$storage->write('config_test.dynamic.dotted.existing', $config_entity_data);
|
||||
$staging->write('config_test.dynamic.dotted.existing', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.existing', $config_entity_data);
|
||||
|
||||
$extensions = $staging->read('core.extension');
|
||||
$extensions = $sync->read('core.extension');
|
||||
// Add a module and a theme that do not exist.
|
||||
$extensions['module']['unknown_module'] = 0;
|
||||
$extensions['theme']['unknown_theme'] = 0;
|
||||
|
@ -579,7 +579,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
$extensions['module']['book'] = 0;
|
||||
$extensions['theme']['bartik'] = 0;
|
||||
|
||||
$staging->write('core.extension', $extensions);
|
||||
$sync->write('core.extension', $extensions);
|
||||
try {
|
||||
$this->configImporter->reset()->import();
|
||||
$this->fail('ConfigImporterException not thrown; an invalid import was not stopped due to missing dependencies.');
|
||||
|
@ -604,13 +604,13 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
}
|
||||
|
||||
// Make a config entity have mulitple unmet dependencies.
|
||||
$config_entity_data = $staging->read('config_test.dynamic.dotted.default');
|
||||
$config_entity_data = $sync->read('config_test.dynamic.dotted.default');
|
||||
$config_entity_data['dependencies'] = ['module' => ['unknown', 'dblog']];
|
||||
$staging->write('config_test.dynamic.dotted.module', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.module', $config_entity_data);
|
||||
$config_entity_data['dependencies'] = ['theme' => ['unknown', 'seven']];
|
||||
$staging->write('config_test.dynamic.dotted.theme', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.theme', $config_entity_data);
|
||||
$config_entity_data['dependencies'] = ['config' => ['unknown', 'unknown2']];
|
||||
$staging->write('config_test.dynamic.dotted.config', $config_entity_data);
|
||||
$sync->write('config_test.dynamic.dotted.config', $config_entity_data);
|
||||
try {
|
||||
$this->configImporter->reset()->import();
|
||||
$this->fail('ConfigImporterException not thrown, invalid import was not stopped due to missing dependencies.');
|
||||
|
@ -635,8 +635,8 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
* @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber
|
||||
*/
|
||||
public function testMissingCoreExtension() {
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$staging->delete('core.extension');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$sync->delete('core.extension');
|
||||
try {
|
||||
$this->configImporter->reset()->import();
|
||||
$this->fail('ConfigImporterException not thrown, invalid import was not stopped due to missing dependencies.');
|
||||
|
@ -654,13 +654,13 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
* @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber
|
||||
*/
|
||||
public function testInstallProfile() {
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
$extensions = $staging->read('core.extension');
|
||||
$extensions = $sync->read('core.extension');
|
||||
// Add an install profile.
|
||||
$extensions['module']['standard'] = 0;
|
||||
|
||||
$staging->write('core.extension', $extensions);
|
||||
$sync->write('core.extension', $extensions);
|
||||
try {
|
||||
$this->configImporter->reset()->import();
|
||||
$this->fail('ConfigImporterException not thrown; an invalid import was not stopped due to missing dependencies.');
|
||||
|
@ -677,8 +677,8 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
* Tests config_get_config_directory().
|
||||
*/
|
||||
public function testConfigGetConfigDirectory() {
|
||||
$directory = config_get_config_directory(CONFIG_STAGING_DIRECTORY);
|
||||
$this->assertEqual($this->configDirectories[CONFIG_STAGING_DIRECTORY], $directory);
|
||||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
$this->assertEqual($this->configDirectories[CONFIG_SYNC_DIRECTORY], $directory);
|
||||
|
||||
$message = 'Calling config_get_config_directory() with CONFIG_ACTIVE_DIRECTORY results in an exception.';
|
||||
try {
|
||||
|
|
|
@ -25,7 +25,7 @@ class ConfigOverrideTest extends KernelTestBase {
|
|||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,15 +93,15 @@ class ConfigOverrideTest extends KernelTestBase {
|
|||
$this->assertIdentical($config->getOriginal('baz', FALSE), $expected_original_data['baz']);
|
||||
$this->assertIdentical($config->getOriginal('404', FALSE), $expected_original_data['404']);
|
||||
|
||||
// Write file to staging.
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
// Write file to sync.
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$expected_new_data = array(
|
||||
'foo' => 'barbar',
|
||||
'404' => 'herpderp',
|
||||
);
|
||||
$staging->write('config_test.system', $expected_new_data);
|
||||
$sync->write('config_test.system', $expected_new_data);
|
||||
|
||||
// Import changed data from staging to active.
|
||||
// Import changed data from sync to active.
|
||||
$this->configImporter()->import();
|
||||
$data = $active->read('config_test.system');
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class ConfigSnapshotTest extends KernelTestBase {
|
|||
// Update the config snapshot. This allows the parent::setUp() to write
|
||||
// configuration files.
|
||||
\Drupal::service('config.manager')->createSnapshot(\Drupal::service('config.storage'), \Drupal::service('config.storage.snapshot'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ class ConfigSnapshotTest extends KernelTestBase {
|
|||
*/
|
||||
function testSnapshot() {
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$snapshot = $this->container->get('config.storage.snapshot');
|
||||
$config_manager = $this->container->get('config.manager');
|
||||
$config_name = 'config_test.system';
|
||||
|
@ -48,7 +48,7 @@ class ConfigSnapshotTest extends KernelTestBase {
|
|||
$new_data = 'foobar';
|
||||
|
||||
$active_snapshot_comparer = new StorageComparer($active, $snapshot, $config_manager);
|
||||
$staging_snapshot_comparer = new StorageComparer($staging, $snapshot, $config_manager);
|
||||
$sync_snapshot_comparer = new StorageComparer($sync, $snapshot, $config_manager);
|
||||
|
||||
// Verify that we have an initial snapshot that matches the active
|
||||
// configuration. This has to be true as no config should be installed.
|
||||
|
@ -66,17 +66,17 @@ class ConfigSnapshotTest extends KernelTestBase {
|
|||
// objects.
|
||||
$this->assertFalse($active_snapshot_comparer->reset()->hasChanges());
|
||||
|
||||
// Change a configuration value in staging.
|
||||
$staging_data = $this->config($config_name)->get();
|
||||
$staging_data[$config_key] = $new_data;
|
||||
$staging->write($config_name, $staging_data);
|
||||
// Change a configuration value in sync.
|
||||
$sync_data = $this->config($config_name)->get();
|
||||
$sync_data[$config_key] = $new_data;
|
||||
$sync->write($config_name, $sync_data);
|
||||
|
||||
// Verify that active and snapshot match, and that staging doesn't match
|
||||
// Verify that active and snapshot match, and that sync doesn't match
|
||||
// active.
|
||||
$this->assertFalse($active_snapshot_comparer->reset()->hasChanges());
|
||||
$this->assertTrue($staging_snapshot_comparer->createChangelist()->hasChanges());
|
||||
$this->assertTrue($sync_snapshot_comparer->createChangelist()->hasChanges());
|
||||
|
||||
// Import changed data from staging to active.
|
||||
// Import changed data from sync to active.
|
||||
$this->configImporter()->import();
|
||||
|
||||
// Verify changed config was properly imported.
|
||||
|
|
|
@ -39,11 +39,11 @@ class ContentTranslationConfigImportTest extends KernelTestBase {
|
|||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('entity_test_mul');
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -68,7 +68,7 @@ class ContentTranslationConfigImportTest extends KernelTestBase {
|
|||
$config_id = $entity_type_id . '.' . $entity_type_id;
|
||||
$config_name = 'language.content_settings.' . $config_id;
|
||||
$storage = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
|
||||
// Verify the configuration to create does not exist yet.
|
||||
$this->assertIdentical($storage->exists($config_name), FALSE, $config_name . ' not found.');
|
||||
|
@ -90,8 +90,8 @@ class ContentTranslationConfigImportTest extends KernelTestBase {
|
|||
'content_translation' => array('enabled' => TRUE),
|
||||
),
|
||||
);
|
||||
$staging->write($config_name, $data);
|
||||
$this->assertIdentical($staging->exists($config_name), TRUE, $config_name . ' found.');
|
||||
$sync->write($config_name, $data);
|
||||
$this->assertIdentical($sync->exists($config_name), TRUE, $config_name . ' found.');
|
||||
|
||||
// Import.
|
||||
$this->configImporter->reset()->import();
|
||||
|
|
|
@ -37,16 +37,16 @@ class FieldImportChangeTest extends FieldUnitTestBase {
|
|||
$field_config_name = "field.field.$field_id";
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
|
||||
// Save as files in the staging directory.
|
||||
// Save as files in the sync directory.
|
||||
$field = $active->read($field_config_name);
|
||||
$new_label = 'Test update import field';
|
||||
$field['label'] = $new_label;
|
||||
$staging->write($field_config_name, $field);
|
||||
$sync->write($field_config_name, $field);
|
||||
|
||||
// Import the content of the staging directory.
|
||||
// Import the content of the sync directory.
|
||||
$this->configImporter()->import();
|
||||
|
||||
// Check that the updated config was correctly imported.
|
||||
|
|
|
@ -77,14 +77,14 @@ class FieldImportCreateTest extends FieldUnitTestBase {
|
|||
*/
|
||||
function testImportCreate() {
|
||||
// A field storage with one single field.
|
||||
$field_name = 'field_test_import_staging';
|
||||
$field_name = 'field_test_import_sync';
|
||||
$field_storage_id = "entity_test.$field_name";
|
||||
$field_id = "entity_test.entity_test.$field_name";
|
||||
$field_storage_config_name = "field.storage.$field_storage_id";
|
||||
$field_config_name = "field.field.$field_id";
|
||||
|
||||
// A field storage with two fields.
|
||||
$field_name_2 = 'field_test_import_staging_2';
|
||||
$field_name_2 = 'field_test_import_sync_2';
|
||||
$field_storage_id_2 = "entity_test.$field_name_2";
|
||||
$field_id_2a = "entity_test.test_bundle.$field_name_2";
|
||||
$field_id_2b = "entity_test.test_bundle_2.$field_name_2";
|
||||
|
@ -93,32 +93,32 @@ class FieldImportCreateTest extends FieldUnitTestBase {
|
|||
$field_config_name_2b = "field.field.$field_id_2b";
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
|
||||
// Add the new files to the staging directory.
|
||||
$src_dir = drupal_get_path('module', 'field_test_config') . '/staging';
|
||||
$target_dir = $this->configDirectories[CONFIG_STAGING_DIRECTORY];
|
||||
// Add the new files to the sync directory.
|
||||
$src_dir = drupal_get_path('module', 'field_test_config') . '/sync';
|
||||
$target_dir = $this->configDirectories[CONFIG_SYNC_DIRECTORY];
|
||||
$this->assertTrue(file_unmanaged_copy("$src_dir/$field_storage_config_name.yml", "$target_dir/$field_storage_config_name.yml"));
|
||||
$this->assertTrue(file_unmanaged_copy("$src_dir/$field_config_name.yml", "$target_dir/$field_config_name.yml"));
|
||||
$this->assertTrue(file_unmanaged_copy("$src_dir/$field_storage_config_name_2.yml", "$target_dir/$field_storage_config_name_2.yml"));
|
||||
$this->assertTrue(file_unmanaged_copy("$src_dir/$field_config_name_2a.yml", "$target_dir/$field_config_name_2a.yml"));
|
||||
$this->assertTrue(file_unmanaged_copy("$src_dir/$field_config_name_2b.yml", "$target_dir/$field_config_name_2b.yml"));
|
||||
|
||||
// Import the content of the staging directory.
|
||||
// Import the content of the sync directory.
|
||||
$this->configImporter()->import();
|
||||
|
||||
// Check that the field and storage were created.
|
||||
$field_storage = FieldStorageConfig::load($field_storage_id);
|
||||
$this->assertTrue($field_storage, 'Test import storage field from staging exists');
|
||||
$this->assertTrue($field_storage, 'Test import storage field from sync exists');
|
||||
$field = FieldConfig::load($field_id);
|
||||
$this->assertTrue($field, 'Test import field from staging exists');
|
||||
$this->assertTrue($field, 'Test import field from sync exists');
|
||||
$field_storage = FieldStorageConfig::load($field_storage_id_2);
|
||||
$this->assertTrue($field_storage, 'Test import storage field 2 from staging exists');
|
||||
$this->assertTrue($field_storage, 'Test import storage field 2 from sync exists');
|
||||
$field = FieldConfig::load($field_id_2a);
|
||||
$this->assertTrue($field, 'Test import field 2a from staging exists');
|
||||
$this->assertTrue($field, 'Test import field 2a from sync exists');
|
||||
$field = FieldConfig::load($field_id_2b);
|
||||
$this->assertTrue($field, 'Test import field 2b from staging exists');
|
||||
$this->assertTrue($field, 'Test import field 2b from sync exists');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,18 +63,18 @@ class FieldImportDeleteTest extends FieldUnitTestBase {
|
|||
$field_storage_uuid_2 = FieldStorageConfig::load($field_storage_id_2)->uuid();
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$this->assertTrue($staging->delete($field_storage_config_name), SafeMarkup::format('Deleted field storage: @field_storage', array('@field_storage' => $field_storage_config_name)));
|
||||
$this->assertTrue($staging->delete($field_storage_config_name_2), SafeMarkup::format('Deleted field storage: @field_storage', array('@field_storage' => $field_storage_config_name_2)));
|
||||
$this->assertTrue($staging->delete($field_config_name), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name)));
|
||||
$this->assertTrue($staging->delete($field_config_name_2a), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name_2a)));
|
||||
$this->assertTrue($staging->delete($field_config_name_2b), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name_2b)));
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
$this->assertTrue($sync->delete($field_storage_config_name), SafeMarkup::format('Deleted field storage: @field_storage', array('@field_storage' => $field_storage_config_name)));
|
||||
$this->assertTrue($sync->delete($field_storage_config_name_2), SafeMarkup::format('Deleted field storage: @field_storage', array('@field_storage' => $field_storage_config_name_2)));
|
||||
$this->assertTrue($sync->delete($field_config_name), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name)));
|
||||
$this->assertTrue($sync->delete($field_config_name_2a), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name_2a)));
|
||||
$this->assertTrue($sync->delete($field_config_name_2b), SafeMarkup::format('Deleted field: @field', array('@field' => $field_config_name_2b)));
|
||||
|
||||
$deletes = $this->configImporter()->getUnprocessedConfiguration('delete');
|
||||
$this->assertEqual(count($deletes), 5, 'Importing configuration will delete 3 fields and 2 field storages.');
|
||||
|
||||
// Import the content of the staging directory.
|
||||
// Import the content of the sync directory.
|
||||
$this->configImporter()->import();
|
||||
|
||||
// Check that the field storages and fields are gone.
|
||||
|
|
|
@ -81,17 +81,17 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase {
|
|||
$unrelated_field_storage->delete();
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
|
||||
// Stage uninstall of the Telephone module.
|
||||
$core_extension = $this->config('core.extension')->get();
|
||||
unset($core_extension['module']['telephone']);
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$sync->write('core.extension', $core_extension);
|
||||
|
||||
// Stage the field deletion
|
||||
$staging->delete('field.storage.entity_test.field_test');
|
||||
$staging->delete('field.field.entity_test.entity_test.field_test');
|
||||
$sync->delete('field.storage.entity_test.field_test');
|
||||
$sync->delete('field.field.entity_test.entity_test.field_test');
|
||||
|
||||
$steps = $this->configImporter()->initialize();
|
||||
$this->assertIdentical($steps[0], array('\Drupal\field\ConfigImporterFieldPurger', 'process'), 'The additional process configuration synchronization step has been added.');
|
||||
|
@ -143,13 +143,13 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase {
|
|||
$field_storage->delete();
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
|
||||
// Stage uninstall of the Telephone module.
|
||||
$core_extension = $this->config('core.extension')->get();
|
||||
unset($core_extension['module']['telephone']);
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$sync->write('core.extension', $core_extension);
|
||||
|
||||
$deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
|
||||
$this->assertTrue(isset($deleted_storages[$field_storage_uuid]), 'Field has been deleted and needs purging before configuration synchronization.');
|
||||
|
|
|
@ -79,17 +79,17 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
|
|||
$this->assertEqual($entity->field_tel[0]->value, $value);
|
||||
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
|
||||
// Stage uninstall of the Telephone module.
|
||||
$core_extension = $this->config('core.extension')->get();
|
||||
unset($core_extension['module']['telephone']);
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$sync->write('core.extension', $core_extension);
|
||||
|
||||
// Stage the field deletion
|
||||
$staging->delete('field.storage.entity_test.field_tel');
|
||||
$staging->delete('field.field.entity_test.entity_test.field_tel');
|
||||
$sync->delete('field.storage.entity_test.field_tel');
|
||||
$sync->delete('field.field.entity_test.entity_test.field_tel');
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
// Test that the message for one field being purged during a configuration
|
||||
// synchronization is correct.
|
||||
|
@ -98,7 +98,7 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
|
|||
// Stage an uninstall of the datetime module to test the message for
|
||||
// multiple fields.
|
||||
unset($core_extension['module']['datetime']);
|
||||
$staging->write('core.extension', $core_extension);
|
||||
$sync->write('core.extension', $core_extension);
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration');
|
||||
$this->assertText('This synchronization will delete data from the fields: entity_test.field_tel, entity_test.field_date.');
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
id: entity_test.entity_test.field_test_import_staging
|
||||
id: entity_test.entity_test.field_test_import_sync
|
||||
uuid: ea711065-6940-47cd-813d-618f64095481
|
||||
langcode: en
|
||||
field_name: field_test_import_staging
|
||||
field_name: field_test_import_sync
|
||||
entity_type: entity_test
|
||||
bundle: entity_test
|
||||
label: 'Import from staging'
|
||||
label: 'Import from sync'
|
||||
description: ''
|
||||
required: '0'
|
||||
default_value: { }
|
||||
|
@ -13,4 +13,4 @@ settings: { }
|
|||
field_type: text
|
||||
dependencies:
|
||||
config:
|
||||
- field.storage.entity_test.field_test_import_staging
|
||||
- field.storage.entity_test.field_test_import_sync
|
|
@ -1,7 +1,7 @@
|
|||
id: entity_test.test_bundle.field_test_import_staging_2
|
||||
id: entity_test.test_bundle.field_test_import_sync_2
|
||||
uuid: f07794a2-d7cc-45b6-b40d-13cf021b5552
|
||||
langcode: en
|
||||
field_name: field_test_import_staging_2
|
||||
field_name: field_test_import_sync_2
|
||||
entity_type: entity_test
|
||||
bundle: test_bundle
|
||||
label: 'Test import field 2 on test bundle'
|
||||
|
@ -13,4 +13,4 @@ settings: { }
|
|||
field_type: text
|
||||
dependencies:
|
||||
config:
|
||||
- field.storage.entity_test.field_test_import_staging_2
|
||||
- field.storage.entity_test.field_test_import_sync_2
|
|
@ -1,7 +1,7 @@
|
|||
id: entity_test.test_bundle_2.field_test_import_staging_2
|
||||
id: entity_test.test_bundle_2.field_test_import_sync_2
|
||||
uuid: 49d6dd19-5097-443d-8f00-fc79525bebce
|
||||
langcode: en
|
||||
field_name: field_test_import_staging_2
|
||||
field_name: field_test_import_sync_2
|
||||
entity_type: entity_test
|
||||
bundle: test_bundle_2
|
||||
label: 'Test import field 2 on test bundle 2'
|
||||
|
@ -13,4 +13,4 @@ settings: { }
|
|||
field_type: text
|
||||
dependencies:
|
||||
config:
|
||||
- field.storage.entity_test.field_test_import_staging_2
|
||||
- field.storage.entity_test.field_test_import_sync_2
|
|
@ -1,7 +1,7 @@
|
|||
id: entity_test.field_test_import_staging
|
||||
id: entity_test.field_test_import_sync
|
||||
uuid: 0bf654cc-f14a-4881-b94c-76959e47466b
|
||||
langcode: en
|
||||
field_name: field_test_import_staging
|
||||
field_name: field_test_import_sync
|
||||
entity_type: entity_test
|
||||
type: text
|
||||
settings:
|
|
@ -1,7 +1,7 @@
|
|||
id: entity_test.field_test_import_staging_2
|
||||
id: entity_test.field_test_import_sync_2
|
||||
uuid: 2165d9aa-9a0c-41a1-be02-2a49f3405c00
|
||||
langcode: en
|
||||
field_name: field_test_import_staging_2
|
||||
field_name: field_test_import_sync_2
|
||||
entity_type: entity_test
|
||||
type: text
|
||||
settings:
|
|
@ -443,11 +443,11 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw($style->buildUrl($original_uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
|
||||
|
||||
// Copy config to staging, and delete the image style.
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
// Copy config to sync, and delete the image style.
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$active = $this->container->get('config.storage');
|
||||
$this->copyConfig($active, $staging);
|
||||
$staging->delete('image.style.' . $style_name);
|
||||
$this->copyConfig($active, $sync);
|
||||
$sync->delete('image.style.' . $style_name);
|
||||
$this->configImporter()->import();
|
||||
|
||||
$this->assertFalse(ImageStyle::load($style_name), 'Style deleted after config import.');
|
||||
|
|
|
@ -29,9 +29,9 @@ class LanguageConfigOverrideImportTest extends WebTestBase {
|
|||
*/
|
||||
public function testConfigOverrideImport() {
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
/* @var \Drupal\Core\Config\StorageInterface $staging */
|
||||
$staging = \Drupal::service('config.storage.staging');
|
||||
$this->copyConfig(\Drupal::service('config.storage'), $staging);
|
||||
/* @var \Drupal\Core\Config\StorageInterface $sync */
|
||||
$sync = \Drupal::service('config.storage.sync');
|
||||
$this->copyConfig(\Drupal::service('config.storage'), $sync);
|
||||
|
||||
// Uninstall the language module and its dependencies so we can test
|
||||
// enabling the language module and creating overrides at the same time
|
||||
|
@ -41,11 +41,11 @@ class LanguageConfigOverrideImportTest extends WebTestBase {
|
|||
// ConfigFactory.
|
||||
$this->rebuildContainer();
|
||||
|
||||
/* @var \Drupal\Core\Config\StorageInterface $override_staging */
|
||||
$override_staging = $staging->createCollection('language.fr');
|
||||
// Create some overrides in staging.
|
||||
$override_staging->write('system.site', array('name' => 'FR default site name'));
|
||||
$override_staging->write('system.maintenance', array('message' => 'FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience'));
|
||||
/* @var \Drupal\Core\Config\StorageInterface $override_sync */
|
||||
$override_sync = $sync->createCollection('language.fr');
|
||||
// Create some overrides in sync.
|
||||
$override_sync->write('system.site', array('name' => 'FR default site name'));
|
||||
$override_sync->write('system.maintenance', array('message' => 'FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience'));
|
||||
|
||||
$this->configImporter()->import();
|
||||
$this->rebuildContainer();
|
||||
|
@ -71,14 +71,14 @@ class LanguageConfigOverrideImportTest extends WebTestBase {
|
|||
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
|
||||
/* @var \Drupal\Core\Config\StorageInterface $staging */
|
||||
$staging = \Drupal::service('config.storage.staging');
|
||||
$this->copyConfig(\Drupal::service('config.storage'), $staging);
|
||||
/* @var \Drupal\Core\Config\StorageInterface $sync */
|
||||
$sync = \Drupal::service('config.storage.sync');
|
||||
$this->copyConfig(\Drupal::service('config.storage'), $sync);
|
||||
|
||||
/* @var \Drupal\Core\Config\StorageInterface $override_staging */
|
||||
$override_staging = $staging->createCollection('language.fr');
|
||||
// Create some overrides in staging.
|
||||
$override_staging->write('system.site', array('name' => 'FR default site name'));
|
||||
/* @var \Drupal\Core\Config\StorageInterface $override_sync */
|
||||
$override_sync = $sync->createCollection('language.fr');
|
||||
// Create some overrides in sync.
|
||||
$override_sync->write('system.site', array('name' => 'FR default site name'));
|
||||
\Drupal::state()->set('config_events_test.event', FALSE);
|
||||
|
||||
$this->configImporter()->import();
|
||||
|
|
|
@ -44,16 +44,16 @@ class NodeImportChangeTest extends KernelTestBase {
|
|||
// Simulate config data to import:
|
||||
// - a modified version (modified label) of the node type config.
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$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;
|
||||
// Save as files in the staging directory.
|
||||
$staging->write($node_type_config_name, $node_type);
|
||||
// Save as files in the sync directory.
|
||||
$sync->write($node_type_config_name, $node_type);
|
||||
|
||||
// Import the content of the staging directory.
|
||||
// Import the content of the sync directory.
|
||||
$this->configImporter()->import();
|
||||
|
||||
// Check that the updated config was correctly imported.
|
||||
|
|
|
@ -61,19 +61,19 @@ class NodeImportCreateTest extends KernelTestBase {
|
|||
|
||||
// Simulate config data to import.
|
||||
$active = $this->container->get('config.storage');
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$this->copyConfig($active, $staging);
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
// Manually add new node type.
|
||||
$src_dir = drupal_get_path('module', 'node_test_config') . '/staging';
|
||||
$target_dir = $this->configDirectories[CONFIG_STAGING_DIRECTORY];
|
||||
$src_dir = drupal_get_path('module', 'node_test_config') . '/sync';
|
||||
$target_dir = $this->configDirectories[CONFIG_SYNC_DIRECTORY];
|
||||
$this->assertTrue(file_unmanaged_copy("$src_dir/$node_type_config_name.yml", "$target_dir/$node_type_config_name.yml"));
|
||||
|
||||
// Import the content of the staging directory.
|
||||
// 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->assertTrue($node_type, 'Import node type from staging was created.');
|
||||
$this->assertTrue($node_type, 'Import node type from sync was created.');
|
||||
$this->assertFalse(FieldConfig::loadByName('node', $node_type_id, 'body'));
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class OptionsFloatFieldImportTest extends FieldTestBase {
|
|||
|
||||
$admin_path = 'admin/structure/types/manage/' . $type . '/fields/node.' . $type . '.' . $field_name . '/storage';
|
||||
|
||||
// Export active config to staging
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
// Export active config to sync.
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
// Set the active to not use dots in the allowed values key names.
|
||||
$edit = array('settings[allowed_values]' => "0|Zero\n1|One");
|
||||
|
|
|
@ -116,20 +116,20 @@ abstract class KernelTestBase extends TestBase {
|
|||
* @see config_get_config_directory()
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* Thrown when CONFIG_STAGING_DIRECTORY cannot be created or made writable.
|
||||
* Thrown when CONFIG_SYNC_DIRECTORY cannot be created or made writable.
|
||||
*/
|
||||
protected function prepareConfigDirectories() {
|
||||
$this->configDirectories = array();
|
||||
include_once DRUPAL_ROOT . '/core/includes/install.inc';
|
||||
// Assign the relative path to the global variable.
|
||||
$path = $this->siteDirectory . '/config_' . CONFIG_STAGING_DIRECTORY;
|
||||
$GLOBALS['config_directories'][CONFIG_STAGING_DIRECTORY] = $path;
|
||||
$path = $this->siteDirectory . '/config_' . CONFIG_SYNC_DIRECTORY;
|
||||
$GLOBALS['config_directories'][CONFIG_SYNC_DIRECTORY] = $path;
|
||||
// Ensure the directory can be created and is writeable.
|
||||
if (!install_ensure_config_directory(CONFIG_STAGING_DIRECTORY)) {
|
||||
throw new \RuntimeException("Failed to create '" . CONFIG_STAGING_DIRECTORY . "' config directory $path");
|
||||
if (!install_ensure_config_directory(CONFIG_SYNC_DIRECTORY)) {
|
||||
throw new \RuntimeException("Failed to create '" . CONFIG_SYNC_DIRECTORY . "' config directory $path");
|
||||
}
|
||||
// Provide the already resolved path for tests.
|
||||
$this->configDirectories[CONFIG_STAGING_DIRECTORY] = $path;
|
||||
$this->configDirectories[CONFIG_SYNC_DIRECTORY] = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1518,7 +1518,7 @@ abstract class TestBase {
|
|||
if (!$this->configImporter) {
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
|
||||
$this->checkSinglePluginConfigSync($entity, 'configuration', 'message', '');
|
||||
|
||||
// Read the existing data, and prepare an altered version in staging.
|
||||
// Read the existing data, and prepare an altered version in sync.
|
||||
$custom_data = $original_data = $this->container->get('config.storage')->read($name);
|
||||
$custom_data['configuration']['message'] = 'Granny Smith';
|
||||
$this->assertConfigUpdateImport($name, $original_data, $custom_data);
|
||||
|
@ -78,7 +78,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
|
||||
$this->checkSinglePluginConfigSync($block, 'settings', 'label', 'Red Delicious');
|
||||
|
||||
// Read the existing data, and prepare an altered version in staging.
|
||||
// Read the existing data, and prepare an altered version in sync.
|
||||
$custom_data = $original_data = $this->container->get('config.storage')->read($name);
|
||||
$custom_data['settings']['label'] = 'Granny Smith';
|
||||
$this->assertConfigUpdateImport($name, $original_data, $custom_data);
|
||||
|
@ -110,7 +110,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
$this->assertIdentical($filters, $entity->get('filters'));
|
||||
$this->assertIdentical($filters, $plugin_collection->getConfiguration());
|
||||
|
||||
// Read the existing data, and prepare an altered version in staging.
|
||||
// Read the existing data, and prepare an altered version in sync.
|
||||
$custom_data = $original_data = $this->container->get('config.storage')->read($name);
|
||||
$custom_data['filters']['filter_url']['settings']['filter_url_length'] = 100;
|
||||
$this->assertConfigUpdateImport($name, $original_data, $custom_data);
|
||||
|
@ -145,7 +145,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
$this->assertIdentical($effects, $entity->get('effects'));
|
||||
$this->assertIdentical($effects, $plugin_collection->getConfiguration());
|
||||
|
||||
// Read the existing data, and prepare an altered version in staging.
|
||||
// Read the existing data, and prepare an altered version in sync.
|
||||
$custom_data = $original_data = $this->container->get('config.storage')->read($name);
|
||||
$effect_name = key($original_data['effects']);
|
||||
|
||||
|
@ -167,7 +167,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
|
||||
$this->checkSinglePluginConfigSync($entity, 'configuration', 'boost', 'bi');
|
||||
|
||||
// Read the existing data, and prepare an altered version in staging.
|
||||
// Read the existing data, and prepare an altered version in sync.
|
||||
$custom_data = $original_data = $this->container->get('config.storage')->read($name);
|
||||
$custom_data['configuration']['boost'] = 'asdf';
|
||||
$this->assertConfigUpdateImport($name, $original_data, $custom_data);
|
||||
|
@ -218,7 +218,7 @@ class ConfigEntityImportTest extends WebTestBase {
|
|||
* The new data to store in the config object.
|
||||
*/
|
||||
public function assertConfigUpdateImport($name, $original_data, $custom_data) {
|
||||
$this->container->get('config.storage.staging')->write($name, $custom_data);
|
||||
$this->container->get('config.storage.sync')->write($name, $custom_data);
|
||||
|
||||
// Verify the active configuration still returns the default values.
|
||||
$config = $this->config($name);
|
||||
|
|
|
@ -51,11 +51,11 @@ class ContentEntityNullStorageTest extends KernelTestBase {
|
|||
$contact_form = ContactForm::create(['id' => 'test']);
|
||||
$contact_form->save();
|
||||
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
|
||||
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
|
||||
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -71,9 +71,9 @@ class ContentEntityNullStorageTest extends KernelTestBase {
|
|||
$this->container->get('string_translation')
|
||||
);
|
||||
|
||||
// Delete the contact message in staging.
|
||||
$staging = $this->container->get('config.storage.staging');
|
||||
$staging->delete($contact_form->getConfigDependencyName());
|
||||
// Delete the contact message in sync.
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$sync->delete($contact_form->getConfigDependencyName());
|
||||
|
||||
// Import.
|
||||
$config_importer->reset()->import();
|
||||
|
|
|
@ -46,12 +46,12 @@ class InstallerExistingSettingsNoProfileTest extends InstallerTestBase {
|
|||
|
||||
// Pre-configure config directories.
|
||||
$this->settings['config_directories'] = array(
|
||||
CONFIG_STAGING_DIRECTORY => (object) array(
|
||||
'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_staging',
|
||||
CONFIG_SYNC_DIRECTORY => (object) array(
|
||||
'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
|
||||
'required' => TRUE,
|
||||
),
|
||||
);
|
||||
mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
|
||||
mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
|
|
@ -55,12 +55,12 @@ class InstallerExistingSettingsTest extends InstallerTestBase {
|
|||
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
|
||||
// Pre-configure config directories.
|
||||
$this->settings['config_directories'] = array(
|
||||
CONFIG_STAGING_DIRECTORY => (object) array(
|
||||
'value' => $site_path . '/files/config_staging',
|
||||
CONFIG_SYNC_DIRECTORY => (object) array(
|
||||
'value' => $site_path . '/files/config_sync',
|
||||
'required' => TRUE,
|
||||
),
|
||||
);
|
||||
mkdir($this->settings['config_directories'][CONFIG_STAGING_DIRECTORY]->value, 0777, TRUE);
|
||||
mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ class ViewEntityDependenciesTest extends ViewKernelTestBase {
|
|||
$dependencies = $view->getDependencies();
|
||||
$this->assertEqual($expected[$view_id], $dependencies);
|
||||
$config = $this->config('views.view.' . $view_id);
|
||||
\Drupal::service('config.storage.staging')->write($view_id, $config->get());
|
||||
\Drupal::service('config.storage.sync')->write($view_id, $config->get());
|
||||
}
|
||||
|
||||
// Ensure that dependencies are calculated on the display level.
|
||||
|
|
|
@ -260,7 +260,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
|||
$this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix);
|
||||
|
||||
mkdir($this->siteDirectory . '/files', 0775);
|
||||
mkdir($this->siteDirectory . '/files/config/' . CONFIG_STAGING_DIRECTORY, 0775, TRUE);
|
||||
mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE);
|
||||
|
||||
// Ensure that all code that relies on drupal_valid_test_ua() can still be
|
||||
// safely executed. This primarily affects the (test) site directory
|
||||
|
@ -278,7 +278,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
|||
new Settings($settings);
|
||||
|
||||
$GLOBALS['config_directories'] = array(
|
||||
CONFIG_STAGING_DIRECTORY => $this->siteDirectory . '/files/config/staging',
|
||||
CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync',
|
||||
);
|
||||
|
||||
foreach (Database::getAllConnectionInfo() as $key => $targets) {
|
||||
|
@ -943,7 +943,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
|||
if (!$this->configImporter) {
|
||||
// Set up the ConfigImporter object for testing.
|
||||
$storage_comparer = new StorageComparer(
|
||||
$this->container->get('config.storage.staging'),
|
||||
$this->container->get('config.storage.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
|
@ -1088,7 +1088,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
|||
if ($name === 'configDirectories') {
|
||||
trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_USER_DEPRECATED);
|
||||
return array(
|
||||
CONFIG_STAGING_DIRECTORY => config_get_config_directory(CONFIG_STAGING_DIRECTORY),
|
||||
CONFIG_SYNC_DIRECTORY => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class KernelTestBaseTest extends KernelTestBase {
|
|||
substr($this->databasePrefix, 10) => array(
|
||||
'files' => array(
|
||||
'config' => array(
|
||||
'staging' => array(),
|
||||
'sync' => array(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -223,13 +223,13 @@ $databases = array();
|
|||
* Location of the site configuration files.
|
||||
*
|
||||
* The $config_directories array specifies the location of file system
|
||||
* directories used for configuration data. On install, "active" and "staging"
|
||||
* directories are created for configuration. The staging directory is used for
|
||||
* directories used for configuration data. On install, "active" and "sync"
|
||||
* directories are created for configuration. The sync directory is used for
|
||||
* configuration imports; the active directory is not used by default, since the
|
||||
* default storage for active configuration is the database rather than the file
|
||||
* system (this can be changed; see "Active configuration settings" below).
|
||||
*
|
||||
* The default location for the active and staging directories is inside a
|
||||
* The default location for the active and sync directories is inside a
|
||||
* randomly-named directory in the public files path; this setting allows you to
|
||||
* override these locations. If you use files for the active configuration, you
|
||||
* can enhance security by putting the active configuration outside your
|
||||
|
@ -238,7 +238,7 @@ $databases = array();
|
|||
* Example:
|
||||
* @code
|
||||
* $config_directories = array(
|
||||
* CONFIG_STAGING_DIRECTORY => '/another/directory/outside/webroot',
|
||||
* CONFIG_SYNC_DIRECTORY => '/another/directory/outside/webroot',
|
||||
* );
|
||||
* @endcode
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue