Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the config module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function config_requirements($phase) {
|
||||
$requirements = [];
|
||||
try {
|
||||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// system_requirements() guarantees that the CONFIG_SYNC_DIRECTORY exists
|
||||
// as the config.storage.staging service relies on it.
|
||||
$directory = FALSE;
|
||||
}
|
||||
// Ensure the configuration sync directory is writable. This is only a warning
|
||||
// because only configuration import from a tarball requires the folder to be
|
||||
// web writable.
|
||||
if ($phase !== 'install' && !is_writable($directory)) {
|
||||
$requirements['config directory ' . CONFIG_SYNC_DIRECTORY] = [
|
||||
'title' => t('Configuration directory: %type', ['%type' => CONFIG_SYNC_DIRECTORY]),
|
||||
'description' => t('The directory %directory is not writable.', ['%directory' => $directory]),
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
];
|
||||
}
|
||||
return $requirements;
|
||||
}
|
|
@ -6,7 +6,6 @@ use Drupal\Core\Config\ConfigEvents;
|
|||
use Drupal\Core\Config\ConfigImporterEvent;
|
||||
use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
|
||||
|
||||
|
||||
/**
|
||||
* Config subscriber.
|
||||
*/
|
||||
|
@ -15,10 +14,15 @@ class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
|
|||
/**
|
||||
* Checks that the Configuration module is not being uninstalled.
|
||||
*
|
||||
* @param ConfigImporterEvent $event
|
||||
* @param \Drupal\Core\Config\ConfigImporterEvent $event
|
||||
* The config import event.
|
||||
*/
|
||||
public function onConfigImporterValidate(ConfigImporterEvent $event) {
|
||||
// Make sure config syncs performed via the Config UI don't break, but
|
||||
// don't worry about syncs initiated via the command line.
|
||||
if (PHP_SAPI === 'cli') {
|
||||
return;
|
||||
}
|
||||
$importer = $event->getConfigImporter();
|
||||
$core_extension = $importer->getStorageComparer()->getSourceStorage()->read('core.extension');
|
||||
if (!isset($core_extension['module']['config'])) {
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
|
||||
/**
|
||||
* Defines the configuration export form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigExportForm extends FormBase {
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
|
||||
/**
|
||||
* Defines the configuration import form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigImportForm extends FormBase {
|
||||
|
||||
|
@ -53,7 +55,7 @@ class ConfigImportForm extends FormBase {
|
|||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
$directory_is_writable = is_writable($directory);
|
||||
if (!$directory_is_writable) {
|
||||
drupal_set_message($this->t('The directory %directory is not writable.', ['%directory' => $directory]), 'error');
|
||||
$this->messenger()->addError($this->t('The directory %directory is not writable.', ['%directory' => $directory]));
|
||||
}
|
||||
$form['import_tarball'] = [
|
||||
'#type' => 'file',
|
||||
|
@ -98,11 +100,11 @@ class ConfigImportForm extends FormBase {
|
|||
$files[] = $file['filename'];
|
||||
}
|
||||
$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.'));
|
||||
$this->messenger()->addStatus($this->t('Your configuration files were successfully uploaded and are ready for import.'));
|
||||
$form_state->setRedirect('config.sync');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', ['@message' => $e->getMessage()]), 'error');
|
||||
$this->messenger()->addError($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', ['@message' => $e->getMessage()]));
|
||||
}
|
||||
drupal_unlink($path);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
|
||||
/**
|
||||
* Provides a form for exporting a single configuration file.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigSingleExportForm extends FormBase {
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||
|
||||
/**
|
||||
* Provides a form for importing a single configuration file.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigSingleImportForm extends ConfirmFormBase {
|
||||
|
||||
|
@ -60,7 +62,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
|
|||
/**
|
||||
* The configuration manager.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface;
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface
|
||||
*/
|
||||
protected $configManager;
|
||||
|
||||
|
@ -393,7 +395,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
|
|||
/** @var \Drupal\Core\Config\ConfigImporter $config_importer */
|
||||
$config_importer = $form_state->get('config_importer');
|
||||
if ($config_importer->alreadyImporting()) {
|
||||
drupal_set_message($this->t('Another request may be importing configuration already.'), 'error');
|
||||
$this->messenger()->addError($this->t('Another request may be importing configuration already.'));
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
@ -414,9 +416,9 @@ class ConfigSingleImportForm extends ConfirmFormBase {
|
|||
}
|
||||
catch (ConfigImporterException $e) {
|
||||
// There are validation errors.
|
||||
drupal_set_message($this->t('The configuration import failed for the following reasons:'), 'error');
|
||||
$this->messenger()->addError($this->t('The configuration import failed for the following reasons:'));
|
||||
foreach ($config_importer->getErrors() as $message) {
|
||||
drupal_set_message($message, 'error');
|
||||
$this->messenger()->addError($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\config\Form;
|
|||
|
||||
use Drupal\Core\Config\ConfigImporterException;
|
||||
use Drupal\Core\Config\ConfigImporter;
|
||||
use Drupal\Core\Config\Importer\ConfigImporterBatch;
|
||||
use Drupal\Core\Config\TypedConfigManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Extension\ModuleInstallerInterface;
|
||||
|
@ -21,6 +22,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
|
||||
/**
|
||||
* Construct the storage changes in a configuration synchronization form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigSync extends FormBase {
|
||||
|
||||
|
@ -62,7 +65,7 @@ class ConfigSync extends FormBase {
|
|||
/**
|
||||
* The configuration manager.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface;
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface
|
||||
*/
|
||||
protected $configManager;
|
||||
|
||||
|
@ -189,7 +192,7 @@ class ConfigSync extends FormBase {
|
|||
return $form;
|
||||
}
|
||||
elseif (!$storage_comparer->validateSiteUuid()) {
|
||||
drupal_set_message($this->t('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'), 'error');
|
||||
$this->messenger()->addError($this->t('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'));
|
||||
$form['actions']['#access'] = FALSE;
|
||||
return $form;
|
||||
}
|
||||
|
@ -212,14 +215,14 @@ class ConfigSync extends FormBase {
|
|||
sort($change_list);
|
||||
$message = [
|
||||
[
|
||||
'#markup' => $this->t('The following items in your active configuration have changes since the last import that may be lost on the next import.')
|
||||
'#markup' => $this->t('The following items in your active configuration have changes since the last import that may be lost on the next import.'),
|
||||
],
|
||||
[
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $change_list,
|
||||
]
|
||||
],
|
||||
];
|
||||
drupal_set_message($this->renderer->renderPlain($message), 'warning');
|
||||
$this->messenger()->addWarning($this->renderer->renderPlain($message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +296,7 @@ class ConfigSync extends FormBase {
|
|||
'class' => ['use-ajax'],
|
||||
'data-dialog-type' => 'modal',
|
||||
'data-dialog-options' => json_encode([
|
||||
'width' => 700
|
||||
'width' => 700,
|
||||
]),
|
||||
],
|
||||
];
|
||||
|
@ -328,31 +331,30 @@ class ConfigSync extends FormBase {
|
|||
$this->getStringTranslation()
|
||||
);
|
||||
if ($config_importer->alreadyImporting()) {
|
||||
drupal_set_message($this->t('Another request may be synchronizing configuration already.'));
|
||||
$this->messenger()->addStatus($this->t('Another request may be synchronizing configuration already.'));
|
||||
}
|
||||
else {
|
||||
try {
|
||||
$sync_steps = $config_importer->initialize();
|
||||
$batch = [
|
||||
'operations' => [],
|
||||
'finished' => [get_class($this), 'finishBatch'],
|
||||
'finished' => [ConfigImporterBatch::class, 'finish'],
|
||||
'title' => t('Synchronizing configuration'),
|
||||
'init_message' => t('Starting configuration synchronization.'),
|
||||
'progress_message' => t('Completed step @current of @total.'),
|
||||
'error_message' => t('Configuration synchronization has encountered an error.'),
|
||||
'file' => __DIR__ . '/../../config.admin.inc',
|
||||
];
|
||||
foreach ($sync_steps as $sync_step) {
|
||||
$batch['operations'][] = [[get_class($this), 'processBatch'], [$config_importer, $sync_step]];
|
||||
$batch['operations'][] = [[ConfigImporterBatch::class, 'process'], [$config_importer, $sync_step]];
|
||||
}
|
||||
|
||||
batch_set($batch);
|
||||
}
|
||||
catch (ConfigImporterException $e) {
|
||||
// There are validation errors.
|
||||
drupal_set_message($this->t('The configuration cannot be imported because it failed validation for the following reasons:'), 'error');
|
||||
$this->messenger()->addError($this->t('The configuration cannot be imported because it failed validation for the following reasons:'));
|
||||
foreach ($config_importer->getErrors() as $message) {
|
||||
drupal_set_message($message, 'error');
|
||||
$this->messenger()->addError($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -367,20 +369,15 @@ class ConfigSync extends FormBase {
|
|||
* The synchronization step to do.
|
||||
* @param array $context
|
||||
* The batch context.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0 and will be removed before 9.0.0. Use
|
||||
* \Drupal\Core\Config\Importer\ConfigImporterBatch::process() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2897299
|
||||
*/
|
||||
public static function processBatch(ConfigImporter $config_importer, $sync_step, &$context) {
|
||||
if (!isset($context['sandbox']['config_importer'])) {
|
||||
$context['sandbox']['config_importer'] = $config_importer;
|
||||
}
|
||||
|
||||
$config_importer = $context['sandbox']['config_importer'];
|
||||
$config_importer->doSyncStep($sync_step, $context);
|
||||
if ($errors = $config_importer->getErrors()) {
|
||||
if (!isset($context['results']['errors'])) {
|
||||
$context['results']['errors'] = [];
|
||||
}
|
||||
$context['results']['errors'] += $errors;
|
||||
}
|
||||
@trigger_error('\Drupal\config\Form\ConfigSync::processBatch() deprecated in Drupal 8.6.0 and will be removed before 9.0.0. Use \Drupal\Core\Config\Importer\ConfigImporterBatch::process() instead. See https://www.drupal.org/node/2897299');
|
||||
ConfigImporterBatch::process($config_importer, $sync_step, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,27 +385,15 @@ class ConfigSync extends FormBase {
|
|||
*
|
||||
* This function is a static function to avoid serializing the ConfigSync
|
||||
* object unnecessarily.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0 and will be removed before 9.0.0. Use
|
||||
* \Drupal\Core\Config\Importer\ConfigImporterBatch::finish() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2897299
|
||||
*/
|
||||
public static function finishBatch($success, $results, $operations) {
|
||||
if ($success) {
|
||||
if (!empty($results['errors'])) {
|
||||
foreach ($results['errors'] as $error) {
|
||||
drupal_set_message($error, 'error');
|
||||
\Drupal::logger('config_sync')->error($error);
|
||||
}
|
||||
drupal_set_message(\Drupal::translation()->translate('The configuration was imported with errors.'), 'warning');
|
||||
}
|
||||
else {
|
||||
drupal_set_message(\Drupal::translation()->translate('The configuration was imported successfully.'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// An error occurred.
|
||||
// $operations contains the operations that remained unprocessed.
|
||||
$error_operation = reset($operations);
|
||||
$message = \Drupal::translation()->translate('An error occurred while processing %error_operation with arguments: @arguments', ['%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)]);
|
||||
drupal_set_message($message, 'error');
|
||||
}
|
||||
@trigger_error('\Drupal\config\Form\ConfigSync::finishBatch() deprecated in Drupal 8.6.0 and will be removed before 9.0.0. Use \Drupal\Core\Config\Importer\ConfigImporterBatch::finish() instead. See https://www.drupal.org/node/2897299');
|
||||
ConfigImporterBatch::finish($success, $results, $operations);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Drupal\config\Tests;
|
||||
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\AssertConfigEntityImportTrait is deprecated in Drupal 8.4.1 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait. See https://www.drupal.org/node/2916197.', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +11,11 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
|||
*
|
||||
* Can be used by test classes that extend \Drupal\simpletest\WebTestBase or
|
||||
* \Drupal\KernelTests\KernelTestBase.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.1 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\config\Traits\AssertConfigEntityImportTrait.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2916197
|
||||
*/
|
||||
trait AssertConfigEntityImportTrait {
|
||||
|
||||
|
|
|
@ -6,4 +6,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_collection_install_test
|
||||
- drupal:config_collection_install_test
|
||||
|
|
|
@ -1 +1 @@
|
|||
collection: another_collection
|
||||
collection: another_collection
|
||||
|
|
|
@ -1 +1 @@
|
|||
collection: collection.test1
|
||||
collection: collection.test1
|
||||
|
|
|
@ -1 +1 @@
|
|||
collection: collection.test2
|
||||
collection: collection.test2
|
||||
|
|
|
@ -18,7 +18,7 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface {
|
|||
return [
|
||||
'config_test.dynamic.test_1' => [
|
||||
'label' => 'Overridden label',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\config_events_test;
|
||||
|
||||
|
||||
use Drupal\Core\Config\ConfigCrudEvent;
|
||||
use Drupal\Core\Config\ConfigEvents;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
|
@ -41,7 +40,7 @@ class EventSubscriber implements EventSubscriberInterface {
|
|||
'event_name' => $name,
|
||||
'current_config_data' => $config->get(),
|
||||
'original_config_data' => $config->getOriginal(),
|
||||
'raw_config_data' => $config->getRawData()
|
||||
'raw_config_data' => $config->getRawData(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Provides configuration import test helpers.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Config\ConfigImporter;
|
||||
|
||||
/**
|
||||
* Implements hook_config_import_steps_alter().
|
||||
*/
|
||||
|
@ -17,9 +19,15 @@ function config_import_test_config_import_steps_alter(&$sync_steps) {
|
|||
*
|
||||
* @param array $context
|
||||
* The batch context.
|
||||
* @param \Drupal\Core\Config\ConfigImporter $config_importer
|
||||
* The configuration importer.
|
||||
*/
|
||||
function _config_import_test_config_import_steps_alter(&$context) {
|
||||
function _config_import_test_config_import_steps_alter(&$context, ConfigImporter $config_importer) {
|
||||
$GLOBALS['hook_config_test']['config_import_steps_alter'] = TRUE;
|
||||
if (\Drupal::state()->get('config_import_steps_alter.error', FALSE)) {
|
||||
$context['results']['errors'][] = '_config_import_test_config_import_steps_alter batch error';
|
||||
$config_importer->logError('_config_import_test_config_import_steps_alter ConfigImporter error');
|
||||
}
|
||||
$context['finished'] = 1;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
id: dependency_for_unmet2
|
||||
label: 'Other module test to test optional config installation'
|
||||
weight: 0
|
||||
style: ''
|
||||
status: true
|
||||
langcode: en
|
||||
protected_property: Default
|
|
@ -4,4 +4,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_test
|
||||
- drupal:config_test
|
||||
|
|
|
@ -4,4 +4,4 @@ package: 'Testing'
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_test
|
||||
- drupal:config_test
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
id: other_module_test_optional_entity_unmet2
|
||||
label: 'Other module test to test optional config installation'
|
||||
weight: 0
|
||||
style: ''
|
||||
status: true
|
||||
langcode: en
|
||||
protected_property: Default
|
||||
dependencies:
|
||||
enforced:
|
||||
config:
|
||||
- config_test.dynamic.dependency_for_unmet2
|
|
@ -5,5 +5,5 @@ version: VERSION
|
|||
core: 8.x
|
||||
|
||||
dependencies:
|
||||
- block
|
||||
- block_test
|
||||
- drupal:block
|
||||
- drupal:block_test
|
||||
|
|
|
@ -5,5 +5,5 @@ version: VERSION
|
|||
core: 8.x
|
||||
|
||||
dependencies:
|
||||
- block
|
||||
- block_content
|
||||
- drupal:block
|
||||
- drupal:block_content
|
||||
|
|
|
@ -18,13 +18,13 @@ class ConfigOverriderLowPriority implements ConfigFactoryOverrideInterface {
|
|||
$overrides = [];
|
||||
if (!empty($GLOBALS['config_test_run_module_overrides'])) {
|
||||
if (in_array('system.site', $names)) {
|
||||
$overrides = ['system.site' =>
|
||||
[
|
||||
$overrides = [
|
||||
'system.site' => [
|
||||
'name' => 'Should not apply because of higher priority listener',
|
||||
// This override should apply because it is not overridden by the
|
||||
// higher priority listener.
|
||||
'slogan' => 'Yay for overrides!',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,17 +61,4 @@ class PirateDayCacheabilityMetadataConfigOverride implements ConfigFactoryOverri
|
|||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not our overrides are potentially applicable.
|
||||
*
|
||||
* @param string $name
|
||||
* The name of the config object that is being constructed.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the merchant ship will be boarded. FALSE if we drink rum instead.
|
||||
*/
|
||||
protected function isCacheabilityMetadataApplicable($name) {
|
||||
return in_array($name, ['system.theme', 'block.block.call_to_action']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -297,3 +297,41 @@ test.double_brackets.breed:
|
|||
mapping:
|
||||
breed:
|
||||
type: string
|
||||
|
||||
config_schema_test.schema_sequence_sort:
|
||||
type: config_object
|
||||
mapping:
|
||||
keyed_sort:
|
||||
type: sequence
|
||||
orderby: key
|
||||
sequence:
|
||||
- type: string
|
||||
value_sort:
|
||||
type: sequence
|
||||
orderby: value
|
||||
sequence:
|
||||
- type: string
|
||||
no_sort:
|
||||
type: sequence
|
||||
sequence:
|
||||
- type: string
|
||||
complex_sort_value:
|
||||
type: sequence
|
||||
orderby: value
|
||||
sequence:
|
||||
- type: mapping
|
||||
mapping:
|
||||
foo:
|
||||
type: string
|
||||
bar:
|
||||
type: string
|
||||
complex_sort_key:
|
||||
type: sequence
|
||||
orderby: key
|
||||
sequence:
|
||||
- type: mapping
|
||||
mapping:
|
||||
foo:
|
||||
type: string
|
||||
bar:
|
||||
type: string
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
llama: llama
|
||||
cat:
|
||||
type: kitten
|
||||
count: 2
|
||||
giraffe:
|
||||
hum1: hum1
|
||||
hum2: hum2
|
||||
uuid: '7C30C50E-641A-4E34-A7F1-46BCFB9BE5A3'
|
|
@ -135,8 +135,7 @@ config_test.new:
|
|||
type: string
|
||||
label: 'Test setting'
|
||||
uuid:
|
||||
type: string
|
||||
label: 'UUID'
|
||||
type: uuid
|
||||
|
||||
config_test.old:
|
||||
type: config_test.new
|
||||
|
@ -158,3 +157,49 @@ config_test.foo:
|
|||
|
||||
config_test.bar:
|
||||
type: config_test.foo
|
||||
|
||||
system.action.*.third_party.config_test:
|
||||
type: mapping
|
||||
label: 'Third party setting for action entity'
|
||||
mapping:
|
||||
integer:
|
||||
type: integer
|
||||
label: 'Integer'
|
||||
|
||||
config_test.validation:
|
||||
type: config_object
|
||||
label: 'Configuration type'
|
||||
constraints:
|
||||
Callback:
|
||||
callback: [\Drupal\config_test\ConfigValidation, validateMapping]
|
||||
mapping:
|
||||
llama:
|
||||
type: string
|
||||
constraints:
|
||||
Callback:
|
||||
callback: [\Drupal\config_test\ConfigValidation, validateLlama]
|
||||
cat:
|
||||
type: mapping
|
||||
mapping:
|
||||
type:
|
||||
type: string
|
||||
constraints:
|
||||
Callback:
|
||||
callback: [\Drupal\config_test\ConfigValidation, validateCats]
|
||||
count:
|
||||
type: integer
|
||||
constraints:
|
||||
Callback:
|
||||
callback: [\Drupal\config_test\ConfigValidation, validateCatCount]
|
||||
giraffe:
|
||||
type: sequence
|
||||
constraints:
|
||||
Callback:
|
||||
callback: [\Drupal\config_test\ConfigValidation, validateSequence]
|
||||
sequence:
|
||||
type: string
|
||||
constraints:
|
||||
Callback:
|
||||
callback: [\Drupal\config_test\ConfigValidation, validateGiraffes]
|
||||
uuid:
|
||||
type: uuid
|
||||
|
|
|
@ -8,6 +8,8 @@ use Drupal\Core\Language\LanguageInterface;
|
|||
|
||||
/**
|
||||
* Form controller for the test config edit forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTestForm extends EntityForm {
|
||||
|
||||
|
@ -136,10 +138,10 @@ class ConfigTestForm extends EntityForm {
|
|||
$status = $entity->save();
|
||||
|
||||
if ($status === SAVED_UPDATED) {
|
||||
drupal_set_message(format_string('%label configuration has been updated.', ['%label' => $entity->label()]));
|
||||
$this->messenger()->addStatus(format_string('%label configuration has been updated.', ['%label' => $entity->label()]));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(format_string('%label configuration has been created.', ['%label' => $entity->label()]));
|
||||
$this->messenger()->addStatus(format_string('%label configuration has been created.', ['%label' => $entity->label()]));
|
||||
}
|
||||
|
||||
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_test;
|
||||
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* Provides a collection of validation callbacks for testing purposes.
|
||||
*/
|
||||
class ConfigValidation {
|
||||
|
||||
/**
|
||||
* Validates a llama.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to validate.
|
||||
* @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateLlama($string, ExecutionContextInterface $context) {
|
||||
if (!in_array($string, ['llama', 'alpaca', 'guanaco', 'vicuña'], TRUE)) {
|
||||
$context->addViolation('no valid llama');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates cats.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to validate.
|
||||
* @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateCats($string, ExecutionContextInterface $context) {
|
||||
if (!in_array($string, ['kitten', 'cats', 'nyans'])) {
|
||||
$context->addViolation('no valid cat');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a number.
|
||||
*
|
||||
* @param int $count
|
||||
* The integer to validate.
|
||||
* @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateCatCount($count, ExecutionContextInterface $context) {
|
||||
if ($count <= 1) {
|
||||
$context->addViolation('no enough cats');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates giraffes.
|
||||
*
|
||||
* @param string $string
|
||||
* The string to validate.
|
||||
* @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateGiraffes($string, ExecutionContextInterface $context) {
|
||||
if (strpos($string, 'hum') !== 0) {
|
||||
$context->addViolation('Giraffes just hum');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a mapping.
|
||||
*
|
||||
* @param array $mapping
|
||||
* The data to validate.
|
||||
* @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateMapping($mapping, ExecutionContextInterface $context) {
|
||||
// Ensure we are validating the entire mapping by diffing against all the
|
||||
// keys.
|
||||
$mapping_schema = \Drupal::service('config.typed')->get('config_test.validation')->getValue();
|
||||
if ($diff = array_diff_key($mapping, $mapping_schema)) {
|
||||
$context->addViolation('Unexpected keys: ' . implode(', ', array_keys($diff)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a sequence.
|
||||
*
|
||||
* @param array $sequence
|
||||
* The data to validate.
|
||||
* @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateSequence($sequence, ExecutionContextInterface $context) {
|
||||
if (isset($sequence['invalid-key'])) {
|
||||
$context->addViolation('Invalid giraffe key.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -113,13 +113,27 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
parent::calculateDependencies();
|
||||
if ($module = \Drupal::state()->get('config_test_new_dependency', FALSE)) {
|
||||
$this->addDependency('module', $module);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function onDependencyRemoval(array $dependencies) {
|
||||
// Record which entities have this method called on.
|
||||
// Record which entities have this method called on and what dependencies
|
||||
// are passed.
|
||||
$called = \Drupal::state()->get('config_test.on_dependency_removal_called', []);
|
||||
$called[] = $this->id();
|
||||
$called[$this->id()] = $dependencies;
|
||||
$called[$this->id()]['config'] = array_keys($called[$this->id()]['config']);
|
||||
$called[$this->id()]['content'] = array_keys($called[$this->id()]['content']);
|
||||
\Drupal::state()->set('config_test.on_dependency_removal_called', $called);
|
||||
|
||||
$changed = parent::onDependencyRemoval($dependencies);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\config_test\Functional\Rest\ConfigTestResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ConfigTestHalJsonAnonTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\config_test\Functional\Rest\ConfigTestResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ConfigTestHalJsonBasicAuthTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal', 'basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\config_test\Functional\Rest\ConfigTestResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ConfigTestHalJsonCookieTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigTestJsonAnonTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigTestJsonBasicAuthTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigTestJsonCookieTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\config_test\Entity\ConfigTest;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
|
||||
|
||||
abstract class ConfigTestResourceTestBase extends EntityResourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['config_test', 'config_test_rest'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $entityTypeId = 'config_test';
|
||||
|
||||
/**
|
||||
* @var \Drupal\config_test\ConfigTestInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpAuthorization($method) {
|
||||
$this->grantPermissionsToTestedRole(['view config_test']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createEntity() {
|
||||
$config_test = ConfigTest::create([
|
||||
'id' => 'llama',
|
||||
'label' => 'Llama',
|
||||
]);
|
||||
$config_test->save();
|
||||
|
||||
return $config_test;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
$normalization = [
|
||||
'uuid' => $this->entity->uuid(),
|
||||
'id' => 'llama',
|
||||
'weight' => 0,
|
||||
'langcode' => 'en',
|
||||
'status' => TRUE,
|
||||
'dependencies' => [],
|
||||
'label' => 'Llama',
|
||||
'style' => NULL,
|
||||
'size' => NULL,
|
||||
'size_value' => NULL,
|
||||
'protected_property' => NULL,
|
||||
];
|
||||
|
||||
return $normalization;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
// @todo Update in https://www.drupal.org/node/2300677.
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigTestXmlAnonTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigTestXmlBasicAuthTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_test\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ConfigTestXmlCookieTest extends ConfigTestResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
id: does_not_match
|
||||
label: Default
|
||||
weight: 0
|
||||
protected_property: Default
|
||||
langcode: en
|
|
@ -0,0 +1,7 @@
|
|||
name: 'Configuration test ID mismatch'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- drupal:config_test
|
|
@ -4,4 +4,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_test
|
||||
- drupal:config_test
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests if configuration overrides correctly affect cacheability metadata.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class CacheabilityMetadataConfigOverrideIntegrationTest extends WebTestBase {
|
||||
class CacheabilityMetadataConfigOverrideIntegrationTest extends BrowserTestBase {
|
||||
|
||||
use AssertPageCacheContextsAndTagsTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests that config overrides do not bleed through in entity forms and lists.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigEntityFormOverrideTest extends WebTestBase {
|
||||
class ConfigEntityFormOverrideTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -46,7 +46,7 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
|
|||
// Test that the original label on the editing page is intact.
|
||||
$this->drupalGet('admin/structure/config_test/manage/dotted.default');
|
||||
$elements = $this->xpath('//input[@name="label"]');
|
||||
$this->assertIdentical((string) $elements[0]['value'], $original_label);
|
||||
$this->assertIdentical($elements[0]->getValue(), $original_label);
|
||||
$this->assertNoText($overridden_label);
|
||||
|
||||
// Change to a new label and test that the listing now has the edited label.
|
||||
|
@ -61,7 +61,7 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
|
|||
// Test that the editing page now has the edited label.
|
||||
$this->drupalGet('admin/structure/config_test/manage/dotted.default');
|
||||
$elements = $this->xpath('//input[@name="label"]');
|
||||
$this->assertIdentical((string) $elements[0]['value'], $edited_label);
|
||||
$this->assertIdentical($elements[0]->getValue(), $edited_label);
|
||||
|
||||
// Test that the overridden label is still loaded with the entity.
|
||||
$this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);
|
|
@ -1,17 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Core\Routing\RedirectDestinationTrait;
|
||||
use Drupal\config_test\Entity\ConfigTest;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the listing of configuration entities.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigEntityListTest extends WebTestBase {
|
||||
class ConfigEntityListTest extends BrowserTestBase {
|
||||
|
||||
use RedirectDestinationTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -54,17 +57,17 @@ class ConfigEntityListTest extends WebTestBase {
|
|||
'edit' => [
|
||||
'title' => t('Edit'),
|
||||
'weight' => 10,
|
||||
'url' => $entity->urlInfo(),
|
||||
'url' => $entity->toUrl()->setOption('query', $this->getRedirectDestination()->getAsArray()),
|
||||
],
|
||||
'disable' => [
|
||||
'title' => t('Disable'),
|
||||
'weight' => 40,
|
||||
'url' => $entity->urlInfo('disable'),
|
||||
'url' => $entity->toUrl('disable')->setOption('query', $this->getRedirectDestination()->getAsArray()),
|
||||
],
|
||||
'delete' => [
|
||||
'title' => t('Delete'),
|
||||
'weight' => 100,
|
||||
'url' => $entity->urlInfo('delete-form'),
|
||||
'url' => $entity->toUrl('delete-form')->setOption('query', $this->getRedirectDestination()->getAsArray()),
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -129,12 +132,12 @@ class ConfigEntityListTest extends WebTestBase {
|
|||
'edit' => [
|
||||
'title' => t('Edit'),
|
||||
'weight' => 10,
|
||||
'url' => $entity->urlInfo(),
|
||||
'url' => $entity->toUrl()->setOption('query', $this->getRedirectDestination()->getAsArray()),
|
||||
],
|
||||
'delete' => [
|
||||
'title' => t('Delete'),
|
||||
'weight' => 100,
|
||||
'url' => $entity->urlInfo('delete-form'),
|
||||
'url' => $entity->toUrl('delete-form')->setOption('query', $this->getRedirectDestination()->getAsArray()),
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -168,7 +171,7 @@ class ConfigEntityListTest extends WebTestBase {
|
|||
// Test the contents of each th cell.
|
||||
$expected_items = ['Label', 'Machine name', 'Operations'];
|
||||
foreach ($elements as $key => $element) {
|
||||
$this->assertIdentical((string) $element[0], $expected_items[$key]);
|
||||
$this->assertIdentical($element->getText(), $expected_items[$key]);
|
||||
}
|
||||
|
||||
// Check the number of table row cells.
|
||||
|
@ -178,9 +181,9 @@ class ConfigEntityListTest extends WebTestBase {
|
|||
// Check the contents of each row cell. The first cell contains the label,
|
||||
// the second contains the machine name, and the third contains the
|
||||
// operations list.
|
||||
$this->assertIdentical((string) $elements[0], 'Default');
|
||||
$this->assertIdentical((string) $elements[1], 'dotted.default');
|
||||
$this->assertTrue($elements[2]->children()->xpath('//ul'), 'Operations list found.');
|
||||
$this->assertIdentical($elements[0]->getText(), 'Default');
|
||||
$this->assertIdentical($elements[1]->getText(), 'dotted.default');
|
||||
$this->assertNotEmpty($elements[2]->find('xpath', '//ul'), 'Operations list found.');
|
||||
|
||||
// Add a new entity using the operations link.
|
||||
$this->assertLink('Add test configuration');
|
||||
|
@ -240,7 +243,7 @@ class ConfigEntityListTest extends WebTestBase {
|
|||
$this->assertNoFieldByXpath('//td', 'dotted.default', "No machine name found for deleted 'Default' entity.");
|
||||
|
||||
// Confirm that the empty text is displayed.
|
||||
$this->assertText('There is no Test configuration yet.');
|
||||
$this->assertText('There are no test configuration entities yet.');
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\EntityMalformedException;
|
||||
use Drupal\Core\Entity\EntityStorageException;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityStorage;
|
||||
use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests configuration entities.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigEntityTest extends WebTestBase {
|
||||
class ConfigEntityTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* The maximum length for the entity storage used in this test.
|
||||
|
@ -35,7 +35,8 @@ class ConfigEntityTest extends WebTestBase {
|
|||
public function testCRUD() {
|
||||
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
|
||||
// Verify default properties on a newly created empty entity.
|
||||
$empty = entity_create('config_test');
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
|
||||
$empty = $storage->create();
|
||||
$this->assertTrue($empty->uuid());
|
||||
$this->assertIdentical($empty->label, NULL);
|
||||
$this->assertIdentical($empty->style, NULL);
|
||||
|
@ -76,7 +77,7 @@ class ConfigEntityTest extends WebTestBase {
|
|||
}
|
||||
|
||||
// Verify that an entity with an empty ID string is considered empty, too.
|
||||
$empty_id = entity_create('config_test', [
|
||||
$empty_id = $storage->create([
|
||||
'id' => '',
|
||||
]);
|
||||
$this->assertIdentical($empty_id->isNew(), TRUE);
|
||||
|
@ -89,7 +90,7 @@ class ConfigEntityTest extends WebTestBase {
|
|||
}
|
||||
|
||||
// Verify properties on a newly created entity.
|
||||
$config_test = entity_create('config_test', $expected = [
|
||||
$config_test = $storage->create($expected = [
|
||||
'id' => $this->randomMachineName(),
|
||||
'label' => $this->randomString(),
|
||||
'style' => $this->randomMachineName(),
|
||||
|
@ -141,26 +142,26 @@ class ConfigEntityTest extends WebTestBase {
|
|||
// maximum allowed length, but not longer.
|
||||
|
||||
// Test with a short ID.
|
||||
$id_length_config_test = entity_create('config_test', [
|
||||
$id_length_config_test = $storage->create([
|
||||
'id' => $this->randomMachineName(8),
|
||||
]);
|
||||
try {
|
||||
$id_length_config_test->save();
|
||||
$this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [
|
||||
'@length' => strlen($id_length_config_test->id())]
|
||||
));
|
||||
$this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
|
||||
'@length' => strlen($id_length_config_test->id()),
|
||||
]));
|
||||
}
|
||||
catch (ConfigEntityIdLengthException $e) {
|
||||
$this->fail($e->getMessage());
|
||||
}
|
||||
|
||||
// Test with an ID of the maximum allowed length.
|
||||
$id_length_config_test = entity_create('config_test', [
|
||||
$id_length_config_test = $storage->create([
|
||||
'id' => $this->randomMachineName(static::MAX_ID_LENGTH),
|
||||
]);
|
||||
try {
|
||||
$id_length_config_test->save();
|
||||
$this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [
|
||||
$this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
|
||||
'@length' => strlen($id_length_config_test->id()),
|
||||
]));
|
||||
}
|
||||
|
@ -169,18 +170,18 @@ class ConfigEntityTest extends WebTestBase {
|
|||
}
|
||||
|
||||
// Test with an ID exceeding the maximum allowed length.
|
||||
$id_length_config_test = entity_create('config_test', [
|
||||
$id_length_config_test = $storage->create([
|
||||
'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1),
|
||||
]);
|
||||
try {
|
||||
$status = $id_length_config_test->save();
|
||||
$this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", [
|
||||
$this->fail(new FormattableMarkup("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", [
|
||||
'@length' => strlen($id_length_config_test->id()),
|
||||
'@max' => static::MAX_ID_LENGTH,
|
||||
]));
|
||||
}
|
||||
catch (ConfigEntityIdLengthException $e) {
|
||||
$this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [
|
||||
$this->pass(new FormattableMarkup("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [
|
||||
'@length' => strlen($id_length_config_test->id()),
|
||||
'@max' => static::MAX_ID_LENGTH,
|
||||
]));
|
||||
|
@ -188,7 +189,7 @@ class ConfigEntityTest extends WebTestBase {
|
|||
|
||||
// Ensure that creating an entity with the same id as an existing one is not
|
||||
// possible.
|
||||
$same_id = entity_create('config_test', [
|
||||
$same_id = $storage->create([
|
||||
'id' => $config_test->id(),
|
||||
]);
|
||||
$this->assertIdentical($same_id->isNew(), TRUE);
|
||||
|
@ -223,7 +224,7 @@ class ConfigEntityTest extends WebTestBase {
|
|||
|
||||
// Test config entity prepopulation.
|
||||
\Drupal::state()->set('config_test.prepopulate', TRUE);
|
||||
$config_test = entity_create('config_test', ['foo' => 'bar']);
|
||||
$config_test = $storage->create(['foo' => 'bar']);
|
||||
$this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated');
|
||||
}
|
||||
|
||||
|
@ -318,28 +319,18 @@ class ConfigEntityTest extends WebTestBase {
|
|||
$this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted');
|
||||
|
||||
// Create a configuration entity with a property that uses AJAX to show
|
||||
// extra form elements.
|
||||
// extra form elements. Test this scenario in a non-JS case by using a
|
||||
// 'js-hidden' submit button.
|
||||
// @see \Drupal\Tests\config\FunctionalJavascript\ConfigEntityTest::testAjaxOnAddPage()
|
||||
$this->drupalGet('admin/structure/config_test/add');
|
||||
|
||||
// Test that the dependent element is not shown initially.
|
||||
$this->assertFieldByName('size');
|
||||
$this->assertNoFieldByName('size_value');
|
||||
|
||||
$id = strtolower($this->randomMachineName());
|
||||
$edit = [
|
||||
'id' => $id,
|
||||
'label' => $this->randomString(),
|
||||
'size' => 'custom',
|
||||
];
|
||||
$this->drupalPostAjaxForm(NULL, $edit, 'size');
|
||||
|
||||
// Check that the dependent element is shown after selecting a 'size' value.
|
||||
$this->assertFieldByName('size');
|
||||
$this->assertFieldByName('size_value');
|
||||
|
||||
// Test the same scenario but it in a non-JS case by using a 'js-hidden'
|
||||
// submit button.
|
||||
$this->drupalGet('admin/structure/config_test/add');
|
||||
$this->assertFieldByName('size');
|
||||
$this->assertNoFieldByName('size_value');
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Archiver\ArchiveTar;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the user interface for importing/exporting configuration.
|
||||
|
@ -17,7 +16,7 @@ use Drupal\simpletest\WebTestBase;
|
|||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigExportImportUITest extends WebTestBase {
|
||||
class ConfigExportImportUITest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* The contents of the config export tarball, held between test methods.
|
||||
|
@ -102,7 +101,7 @@ class ConfigExportImportUITest extends WebTestBase {
|
|||
$this->contentType = $this->drupalCreateContentType();
|
||||
|
||||
// Create a field.
|
||||
$this->fieldName = Unicode::strtolower($this->randomMachineName());
|
||||
$this->fieldName = mb_strtolower($this->randomMachineName());
|
||||
$this->fieldStorage = FieldStorageConfig::create([
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'node',
|
||||
|
@ -135,7 +134,7 @@ class ConfigExportImportUITest extends WebTestBase {
|
|||
|
||||
// Export the configuration.
|
||||
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
|
||||
$this->tarball = $this->getRawContent();
|
||||
$this->tarball = $this->getSession()->getPage()->getContent();
|
||||
|
||||
$this->config('system.site')
|
||||
->set('slogan', $this->originalSlogan)
|
||||
|
@ -225,7 +224,7 @@ class ConfigExportImportUITest extends WebTestBase {
|
|||
|
||||
// Export the configuration.
|
||||
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
|
||||
$this->tarball = $this->getRawContent();
|
||||
$this->tarball = $this->getSession()->getPage()->getContent();
|
||||
$filename = file_directory_temp() . '/' . $this->randomMachineName();
|
||||
file_put_contents($filename, $this->tarball);
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Core\Archiver\Tar;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the user interface for exporting configuration.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigExportUITest extends WebTestBase {
|
||||
class ConfigExportUITest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -44,7 +44,8 @@ class ConfigExportUITest extends WebTestBase {
|
|||
$this->drupalGet('admin/config/development/configuration/full/export');
|
||||
$this->assertFieldById('edit-submit', t('Export'));
|
||||
|
||||
// Submit the export form and verify response.
|
||||
// Submit the export form and verify response. This will create a file in
|
||||
// temporary directory with the default name config.tar.gz.
|
||||
$this->drupalPostForm('admin/config/development/configuration/full/export', [], t('Export'));
|
||||
$this->assertResponse(200, 'User can access the download callback.');
|
||||
|
||||
|
@ -55,14 +56,8 @@ class ConfigExportUITest extends WebTestBase {
|
|||
$header_match = (boolean) preg_match('/attachment; filename="config-' . preg_quote($hostname) . '-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}\.tar\.gz"/', $header_content_disposition);
|
||||
$this->assertTrue($header_match, "Header with filename matches the expected format.");
|
||||
|
||||
// Get the archived binary file provided to user for download.
|
||||
$archive_data = $this->getRawContent();
|
||||
|
||||
// Temporarily save the archive file.
|
||||
$uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
|
||||
|
||||
// Extract the archive and verify it's not empty.
|
||||
$file_path = file_directory_temp() . '/' . file_uri_target($uri);
|
||||
$file_path = file_directory_temp() . '/' . 'config.tar.gz';
|
||||
$archiver = new Tar($file_path);
|
||||
$archive_contents = $archiver->listContents();
|
||||
$this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests config overrides do not appear on forms that extend ConfigFormBase.
|
||||
|
@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase;
|
|||
* @group config
|
||||
* @see \Drupal\Core\Form\ConfigFormBase
|
||||
*/
|
||||
class ConfigFormOverrideTest extends WebTestBase {
|
||||
class ConfigFormOverrideTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Tests that overrides do not affect forms.
|
||||
|
@ -32,7 +32,7 @@ class ConfigFormOverrideTest extends WebTestBase {
|
|||
$this->drupalGet('admin/config/system/site-information');
|
||||
$this->assertTitle('Basic site settings | ' . $overridden_name);
|
||||
$elements = $this->xpath('//input[@name="site_name"]');
|
||||
$this->assertIdentical((string) $elements[0]['value'], 'Drupal');
|
||||
$this->assertIdentical($elements[0]->getValue(), 'Drupal');
|
||||
|
||||
// Submit the form and ensure the site name is not changed.
|
||||
$edit = [
|
||||
|
@ -41,7 +41,7 @@ class ConfigFormOverrideTest extends WebTestBase {
|
|||
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
|
||||
$this->assertTitle('Basic site settings | ' . $overridden_name);
|
||||
$elements = $this->xpath('//input[@name="site_name"]');
|
||||
$this->assertIdentical((string) $elements[0]['value'], $edit['site_name']);
|
||||
$this->assertIdentical($elements[0]->getValue(), $edit['site_name']);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Core\Config\StorageComparer;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\system\Tests\Module\ModuleTestBase;
|
||||
use Drupal\shortcut\Entity\Shortcut;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\Core\Entity\ContentEntityTypeInterface;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\system\Functional\Module\ModuleTestBase;
|
||||
|
||||
/**
|
||||
* Tests the largest configuration import possible with all available modules.
|
||||
|
@ -71,33 +70,29 @@ class ConfigImportAllTest extends ModuleTestBase {
|
|||
system_list_reset();
|
||||
$this->resetAll();
|
||||
|
||||
// Delete every field on the site so all modules can be uninstalled. For
|
||||
// example, if a comment field exists then module becomes required and can
|
||||
// not be uninstalled.
|
||||
// Delete all entities provided by modules that prevent uninstallation. For
|
||||
// example, if any content entity exists its provider cannot be uninstalled.
|
||||
// So deleting all taxonomy terms allows the Taxonomy to be uninstalled.
|
||||
// Additionally, every field is deleted so modules can be uninstalled. For
|
||||
// example, if a comment field exists then Comment cannot be uninstalled.
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
foreach ($entity_type_manager->getDefinitions() as $entity_type) {
|
||||
if (($entity_type instanceof ContentEntityTypeInterface || in_array($entity_type->id(), ['field_storage_config', 'filter_format'], TRUE))
|
||||
&& !in_array($entity_type->getProvider(), ['system', 'user'], TRUE)) {
|
||||
$storage = $entity_type_manager->getStorage($entity_type->id());
|
||||
$storage->delete($storage->loadMultiple());
|
||||
}
|
||||
}
|
||||
|
||||
$field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple();
|
||||
\Drupal::entityManager()->getStorage('field_storage_config')->delete($field_storages);
|
||||
// Purge the data.
|
||||
// Purge the field data.
|
||||
field_purge_batch(1000);
|
||||
|
||||
// Delete all terms.
|
||||
$terms = Term::loadMultiple();
|
||||
entity_delete_multiple('taxonomy_term', array_keys($terms));
|
||||
|
||||
// Delete all filter formats.
|
||||
$filters = FilterFormat::loadMultiple();
|
||||
entity_delete_multiple('filter_format', array_keys($filters));
|
||||
|
||||
// Delete any shortcuts so the shortcut module can be uninstalled.
|
||||
$shortcuts = Shortcut::loadMultiple();
|
||||
entity_delete_multiple('shortcut', array_keys($shortcuts));
|
||||
|
||||
system_list_reset();
|
||||
$all_modules = system_rebuild_module_data();
|
||||
|
||||
// Ensure that only core required modules and the install profile can not be uninstalled.
|
||||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(array_keys($all_modules));
|
||||
$this->assertEqual(['standard', 'system', 'user'], array_keys($validation_reasons));
|
||||
$this->assertEqual(['system', 'user', 'standard'], array_keys($validation_reasons));
|
||||
|
||||
$modules_to_uninstall = array_filter($all_modules, function ($module) use ($validation_reasons) {
|
||||
// Filter required and not enabled modules.
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the importing/exporting configuration based on the install profile.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigImportInstallProfileTest extends WebTestBase {
|
||||
class ConfigImportInstallProfileTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* The profile to install as a basis for testing.
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the user interface for importing/exporting configuration.
|
||||
* Tests the user interface for importing configuration.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigImportUITest extends WebTestBase {
|
||||
class ConfigImportUITest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
|
@ -130,6 +130,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
// Verify that there are no further changes to import.
|
||||
$this->assertText(t('There are no configuration changes to import.'));
|
||||
|
||||
$this->rebuildContainer();
|
||||
// Verify site name has changed.
|
||||
$this->assertIdentical($new_site_name, $this->config('system.site')->get('name'));
|
||||
|
||||
|
@ -432,7 +433,7 @@ class ConfigImportUITest extends WebTestBase {
|
|||
|
||||
// Attempt to import configuration and verify that an error message appears.
|
||||
$this->drupalPostForm(NULL, [], t('Import all'));
|
||||
$this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary]));
|
||||
$this->assertText(new FormattableMarkup('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary]));
|
||||
$this->assertText(t('The configuration was imported with errors.'));
|
||||
$this->assertNoText(t('The configuration was imported successfully.'));
|
||||
$this->assertText(t('There are no configuration changes to import.'));
|
||||
|
@ -517,4 +518,17 @@ class ConfigImportUITest extends WebTestBase {
|
|||
$this->assertText('Unable to install the does_not_exist theme since it does not exist.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that errors set in the batch and on the ConfigImporter are merged.
|
||||
*/
|
||||
public function testBatchErrors() {
|
||||
$new_site_name = 'Config import test ' . $this->randomString();
|
||||
$this->prepareSiteNameUpdate($new_site_name);
|
||||
\Drupal::state()->set('config_import_steps_alter.error', TRUE);
|
||||
$this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
|
||||
$this->assertSession()->responseContains('_config_import_test_config_import_steps_alter batch error');
|
||||
$this->assertSession()->responseContains('_config_import_test_config_import_steps_alter ConfigImporter error');
|
||||
$this->assertSession()->responseContains('The configuration was imported with errors.');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Tests\TestFileCreationTrait;
|
||||
|
||||
/**
|
||||
* Tests importing configuration from an uploaded file.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigImportUploadTest extends WebTestBase {
|
||||
class ConfigImportUploadTest extends BrowserTestBase {
|
||||
|
||||
use TestFileCreationTrait;
|
||||
|
||||
/**
|
||||
* A user with the 'import configuration' permission.
|
||||
|
@ -41,8 +44,8 @@ class ConfigImportUploadTest extends WebTestBase {
|
|||
$this->assertResponse(200);
|
||||
|
||||
// Attempt to upload a non-tar file.
|
||||
$text_file = current($this->drupalGetTestFiles('text'));
|
||||
$edit = ['files[import_tarball]' => drupal_realpath($text_file->uri)];
|
||||
$text_file = $this->getTestFiles('text')[0];
|
||||
$edit = ['files[import_tarball]' => \Drupal::service('file_system')->realpath($text_file->uri)];
|
||||
$this->drupalPostForm('admin/config/development/configuration/full/import', $edit, t('Upload'));
|
||||
$this->assertText(t('Could not extract the contents of the tar file'));
|
||||
|
|
@ -24,7 +24,6 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase {
|
|||
*/
|
||||
protected $profile = 'testing_config_overrides';
|
||||
|
||||
|
||||
/**
|
||||
* Tests install profile config changes.
|
||||
*/
|
||||
|
@ -108,7 +107,16 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase {
|
|||
$this->container->get('module_installer')->install(['dblog']);
|
||||
$this->rebuildContainer();
|
||||
$this->assertEqual($config_test_storage->load('override_unmet')->label(), 'Override', 'The optional config_test entity is overridden by the profile optional configuration and is installed when its dependencies are met.');
|
||||
$this->assertEqual($config_test_storage->load('completely_new')->label(), 'Completely new optional configuration', 'The optional config_test entity is provided by the profile optional configuration and is installed when its dependencies are met.');
|
||||
$config_test_new = $config_test_storage->load('completely_new');
|
||||
$this->assertEqual($config_test_new->label(), 'Completely new optional configuration', 'The optional config_test entity is provided by the profile optional configuration and is installed when its dependencies are met.');
|
||||
$config_test_new->delete();
|
||||
|
||||
// Install another module that provides optional configuration and ensure
|
||||
// that deleted profile configuration is not re-created.
|
||||
$this->container->get('module_installer')->install(['config_other_module_config_test']);
|
||||
$this->rebuildContainer();
|
||||
$config_test_storage = \Drupal::entityManager()->getStorage('config_test');
|
||||
$this->assertNull($config_test_storage->load('completely_new'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\FunctionalTests\Installer\InstallerTestBase;
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
use Drupal\simpletest\InstallerTestBase;
|
||||
|
||||
/**
|
||||
* Tests install profile config overrides can not add unmet dependencies.
|
||||
|
@ -21,16 +21,41 @@ class ConfigInstallProfileUnmetDependenciesTest extends InstallerTestBase {
|
|||
protected $profile = 'testing_config_overrides';
|
||||
|
||||
/**
|
||||
* Set to TRUE if the expected exception is thrown.
|
||||
* Contains the expected exception if it is thrown.
|
||||
*
|
||||
* @var bool
|
||||
* @var \Drupal\Core\Config\UnmetDependenciesException
|
||||
*/
|
||||
protected $expectedException = FALSE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function prepareEnvironment() {
|
||||
parent::prepareEnvironment();
|
||||
$this->copyTestingOverrides();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
// Copy the testing_config_overrides install profile so we can change the
|
||||
// configuration to include a dependency that can not be met. File API
|
||||
// functions are not available yet.
|
||||
// During set up an UnmetDependenciesException should be thrown, which will
|
||||
// be re-thrown by TestHttpClientMiddleware as a standard Exception.
|
||||
try {
|
||||
parent::setUp();
|
||||
}
|
||||
catch (\Exception $exception) {
|
||||
$this->expectedException = $exception;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the testing_config_overrides install profile.
|
||||
*
|
||||
* So we can change the configuration to include a dependency that can not be
|
||||
* met. File API functions are not available yet.
|
||||
*/
|
||||
protected function copyTestingOverrides() {
|
||||
$dest = $this->siteDirectory . '/profiles/testing_config_overrides';
|
||||
mkdir($dest, 0777, TRUE);
|
||||
$source = DRUPAL_ROOT . '/core/profiles/testing_config_overrides';
|
||||
|
@ -50,47 +75,19 @@ class ConfigInstallProfileUnmetDependenciesTest extends InstallerTestBase {
|
|||
$action = Yaml::decode(file_get_contents($config_file));
|
||||
$action['dependencies']['module'][] = 'action';
|
||||
file_put_contents($config_file, Yaml::encode($action));
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Override the error method so we can test for the expected exception.
|
||||
*/
|
||||
protected function error($message = '', $group = 'Other', array $caller = NULL) {
|
||||
if ($group == 'User notice') {
|
||||
// Since 'User notice' is set by trigger_error() which is used for debug
|
||||
// set the message to a status of 'debug'.
|
||||
return $this->assert('debug', $message, 'Debug', $caller);
|
||||
}
|
||||
if ($group == 'Drupal\Core\Config\UnmetDependenciesException') {
|
||||
$this->expectedException = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
return $this->assert('exception', $message, $group, $caller);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpSite() {
|
||||
// This step is not reached due to the exception.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Confirms that the installation succeeded.
|
||||
*/
|
||||
public function testInstalled() {
|
||||
if ($this->expectedException) {
|
||||
$this->pass('Expected Drupal\Core\Config\UnmetDependenciesException exception thrown');
|
||||
$this->assertContains('Configuration objects provided by <em class="placeholder">user</em> have unmet dependencies: <em class="placeholder">system.action.user_block_user_action (action)</em>', $this->expectedException->getMessage());
|
||||
$this->assertContains('Drupal\Core\Config\UnmetDependenciesException', $this->expectedException->getMessage());
|
||||
}
|
||||
else {
|
||||
$this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception thrown');
|
||||
$this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception not thrown');
|
||||
}
|
||||
$this->assertErrorLogged('Configuration objects provided by <em class="placeholder">user</em> have unmet dependencies: <em class="placeholder">system.action.user_block_user_action (action)</em>');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Core\Config\PreExistingConfigException;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests installation and removal of configuration objects in install, disable
|
||||
|
@ -13,7 +13,7 @@ use Drupal\simpletest\WebTestBase;
|
|||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigInstallWebTest extends WebTestBase {
|
||||
class ConfigInstallWebTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* The admin user used in this test.
|
||||
|
@ -51,6 +51,7 @@ class ConfigInstallWebTest extends WebTestBase {
|
|||
|
||||
// Install the integration module.
|
||||
\Drupal::service('module_installer')->install(['config_integration_test']);
|
||||
$this->resetAll();
|
||||
|
||||
// Verify that default module config exists.
|
||||
\Drupal::configFactory()->reset($default_config);
|
||||
|
@ -156,7 +157,7 @@ class ConfigInstallWebTest extends WebTestBase {
|
|||
// override created still exists.
|
||||
$this->drupalGet('admin/appearance');
|
||||
$url = $this->xpath("//a[contains(@href,'config_clash_test_theme') and contains(@href,'/install?')]/@href")[0];
|
||||
$this->drupalGet($this->getAbsoluteUrl($url));
|
||||
$this->drupalGet($this->getAbsoluteUrl($url->getText()));
|
||||
$this->assertRaw('Unable to install config_clash_test_theme, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
|
||||
|
||||
// Test installing a theme through the API that has existing configuration.
|
||||
|
@ -203,11 +204,6 @@ class ConfigInstallWebTest extends WebTestBase {
|
|||
file_unmanaged_delete_recursive($directory);
|
||||
$this->drupalGet('/admin/reports/status');
|
||||
$this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory]));
|
||||
|
||||
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
|
||||
\Drupal::service('file_system')->chmod($directory, 0555);
|
||||
$this->drupalGet('/admin/reports/status');
|
||||
$this->assertRaw(t('The directory %directory is not writable.', ['%directory' => $directory]));
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ class ConfigLanguageOverrideWebTest extends BrowserTestBase {
|
|||
public static $modules = [
|
||||
'block',
|
||||
'language',
|
||||
'system'
|
||||
'system',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,12 +62,29 @@ class ConfigOtherModuleTest extends BrowserTestBase {
|
|||
$this->assertNull(entity_load('config_test', 'other_module_test_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_unmet whose dependencies are not met is not created.');
|
||||
$this->assertNull(entity_load('config_test', 'other_module_test_optional_entity_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are not met is not created.');
|
||||
$this->installModule('config_test_language');
|
||||
$this->assertNull(entity_load('config_test', 'other_module_test_optional_entity_unmet2', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet2 whose dependencies are not met is not created.');
|
||||
$this->installModule('config_install_dependency_test');
|
||||
$this->assertTrue(entity_load('config_test', 'other_module_test_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_unmet whose dependencies are met is now created.');
|
||||
// Although the following configuration entity's are now met it is not
|
||||
// installed because it does not have a direct dependency on the
|
||||
// config_install_dependency_test module.
|
||||
$this->assertNull(entity_load('config_test', 'other_module_test_optional_entity_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are met is not created.');
|
||||
// The following configuration entity's dependencies are now met. It is
|
||||
// indirectly dependent on the config_install_dependency_test module because
|
||||
// it has a dependency on the config_test.dynamic.dependency_for_unmet2
|
||||
// configuration provided by that module and, therefore, should be created.
|
||||
$this->assertTrue(entity_load('config_test', 'other_module_test_optional_entity_unmet2', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet2 whose dependencies are met is now created.');
|
||||
|
||||
// The following configuration entity's dependencies are now met even though
|
||||
// it has no direct dependency on the module. It is indirectly dependent on
|
||||
// the config_install_dependency_test module because it has a dependency on
|
||||
// the config_test.dynamic.other_module_test_unmet configuration that is
|
||||
// dependent on the config_install_dependency_test module and, therefore,
|
||||
// should be created.
|
||||
$entity = entity_load('config_test', 'other_module_test_optional_entity_unmet', TRUE);
|
||||
$this->assertTrue($entity, 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are met is created.');
|
||||
$entity->delete();
|
||||
|
||||
// Install another module to ensure the configuration just deleted is not
|
||||
// recreated.
|
||||
$this->installModule('config');
|
||||
$this->assertFalse(entity_load('config_test', 'other_module_test_optional_entity_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are met is not installed when an unrelated module is installed.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the user interface for importing/exporting a single configuration.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigSingleImportExportTest extends WebTestBase {
|
||||
class ConfigSingleImportExportTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -172,12 +172,24 @@ EOD;
|
|||
'import' => $import,
|
||||
];
|
||||
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
|
||||
$this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
|
||||
$this->drupalPostForm(NULL, [], t('Confirm'));
|
||||
$entity = $storage->load('second');
|
||||
$this->assertRaw(t('The configuration was imported successfully.'));
|
||||
$this->assertTrue(is_string($entity->label()), 'Entity label is a string');
|
||||
$this->assertTrue(strpos($entity->label(), 'ObjectSerialization') > 0, 'Label contains serialized object');
|
||||
if (extension_loaded('yaml')) {
|
||||
// If the yaml extension is loaded it will work but not create the PHP
|
||||
// object.
|
||||
$this->assertRaw(t('Are you sure you want to update the %name @type?', [
|
||||
'%name' => 'second',
|
||||
'@type' => 'test configuration',
|
||||
]));
|
||||
$this->drupalPostForm(NULL, [], t('Confirm'));
|
||||
$entity = $storage->load('second');
|
||||
$this->assertRaw(t('The configuration was imported successfully.'));
|
||||
$this->assertTrue(is_string($entity->label()), 'Entity label is a string');
|
||||
$this->assertTrue(strpos($entity->label(), 'ObjectSerialization') > 0, 'Label contains serialized object');
|
||||
}
|
||||
else {
|
||||
// If the Symfony parser is used there will be an error.
|
||||
$this->assertSession()->responseContains('The import failed with the following message:');
|
||||
$this->assertSession()->responseContains('Object support when parsing a YAML file has been disabled');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,16 +237,16 @@ EOD;
|
|||
$this->drupalGet('admin/config/development/configuration/single/export/system.simple');
|
||||
$this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Simple configuration'), 'The simple configuration option is selected when specified in the URL.');
|
||||
// Spot check several known simple configuration files.
|
||||
$element = $this->xpath('//select[@name="config_name"]');
|
||||
$options = $this->getAllOptions($element[0]);
|
||||
$element = $this->xpath('//select[@name="config_name"]')[0];
|
||||
$options = $element->findAll('css', 'option');
|
||||
$expected_options = ['system.site', 'user.settings'];
|
||||
foreach ($options as &$option) {
|
||||
$option = (string) $option;
|
||||
$option = $option->getValue();
|
||||
}
|
||||
$this->assertIdentical($expected_options, array_intersect($expected_options, $options), 'The expected configuration files are listed.');
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/system.simple/system.image');
|
||||
$this->assertFieldByXPath('//textarea[@name="export"]', "toolkit: gd\n_core:\n default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\n", 'The expected system configuration is displayed.');
|
||||
$this->assertEquals("toolkit: gd\n_core:\n default_config_hash: durWHaKeBaq4d9Wpi4RqwADj1OufDepcnJuhVLmKN24\n", $this->xpath('//textarea[@name="export"]')[0]->getValue(), 'The expected system configuration is displayed.');
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/date_format');
|
||||
$this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Date format'), 'The date format entity type is selected when specified in the URL.');
|
||||
|
@ -243,7 +255,7 @@ EOD;
|
|||
$this->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format (fallback)'), 'The fallback date format config entity is selected when specified in the URL.');
|
||||
|
||||
$fallback_date = \Drupal::entityManager()->getStorage('date_format')->load('fallback');
|
||||
$yaml_text = (string) $this->xpath('//textarea[@name="export"]')[0];
|
||||
$yaml_text = $this->xpath('//textarea[@name="export"]')[0]->getValue();
|
||||
$this->assertEqual(Yaml::decode($yaml_text), $fallback_date->toArray(), 'The fallback date format config entity export code is displayed.');
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config\Tests;
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests language-negotiation overrides are not on language-negotiation form.
|
||||
|
@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase;
|
|||
* @group config
|
||||
* @see \Drupal\Core\Form\ConfigFormBase
|
||||
*/
|
||||
class LanguageNegotiationFormOverrideTest extends WebTestBase {
|
||||
class LanguageNegotiationFormOverrideTest extends BrowserTestBase {
|
||||
|
||||
public static $modules = ['language', 'locale', 'locale_test'];
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the Config operations through the UI.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigEntityTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['config_test'];
|
||||
|
||||
/**
|
||||
* Tests ajax operations through the UI on 'Add' page.
|
||||
*/
|
||||
public function testAjaxOnAddPage() {
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
|
||||
|
||||
$page = $this->getSession()->getPage();
|
||||
$assert_session = $this->assertSession();
|
||||
|
||||
$this->drupalGet('admin/structure/config_test/add');
|
||||
// Test that 'size value' field is not show initially, and it is show after
|
||||
// selecting value in the 'size' field.
|
||||
$this->assertNull($page->findField('size_value'));
|
||||
$page->findField('size')->setValue('custom');
|
||||
$this->assertNotNull($assert_session->waitForField('size_value'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config\Kernel;
|
||||
|
||||
use Drupal\Core\Config\ConfigImporter;
|
||||
use Drupal\Core\Config\StorageComparer;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests importing configuration from files into active configuration.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigUninstallViaCliImportTest extends KernelTestBase {
|
||||
/**
|
||||
* Config Importer object used for testing.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigImporter
|
||||
*/
|
||||
protected $configImporter;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['system', 'config'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
$this->markTestSkipped('This test has to be run from the CLI');
|
||||
}
|
||||
|
||||
$this->installConfig(['system']);
|
||||
$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.sync'),
|
||||
$this->container->get('config.storage'),
|
||||
$this->container->get('config.manager')
|
||||
);
|
||||
$this->configImporter = new ConfigImporter(
|
||||
$storage_comparer->createChangelist(),
|
||||
$this->container->get('event_dispatcher'),
|
||||
$this->container->get('config.manager'),
|
||||
$this->container->get('lock'),
|
||||
$this->container->get('config.typed'),
|
||||
$this->container->get('module_handler'),
|
||||
$this->container->get('module_installer'),
|
||||
$this->container->get('theme_handler'),
|
||||
$this->container->get('string_translation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the config module can be uninstalled via CLI config import.
|
||||
*
|
||||
* @see \Drupal\config\ConfigSubscriber
|
||||
*/
|
||||
public function testConfigUninstallViaCli() {
|
||||
$this->assertTrue($this->container->get('module_handler')->moduleExists('config'));
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$extensions = $sync->read('core.extension');
|
||||
unset($extensions['module']['config']);
|
||||
$sync->write('core.extension', $extensions);
|
||||
$this->configImporter->reset()->import();
|
||||
$this->assertFalse($this->container->get('module_handler')->moduleExists('config'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config\Traits;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
||||
|
||||
/**
|
||||
* Provides test assertions for testing config entity synchronization.
|
||||
*
|
||||
* Can be used by test classes that extend \Drupal\Tests\BrowserTestBase or
|
||||
* \Drupal\KernelTests\KernelTestBase.
|
||||
*/
|
||||
trait AssertConfigEntityImportTrait {
|
||||
|
||||
/**
|
||||
* Asserts that a config entity can be imported without changing it.
|
||||
*
|
||||
* @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
|
||||
* The config entity to test importing.
|
||||
*/
|
||||
public function assertConfigEntityImport(ConfigEntityInterface $entity) {
|
||||
// Save original config information.
|
||||
$entity_uuid = $entity->uuid();
|
||||
$entity_type_id = $entity->getEntityTypeId();
|
||||
$original_data = $entity->toArray();
|
||||
// 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.
|
||||
$entity->delete();
|
||||
$this->configImporter()->reset()->import();
|
||||
$imported_entity = \Drupal::service('entity.repository')->loadEntityByUuid($entity_type_id, $entity_uuid);
|
||||
$this->assertIdentical($original_data, $imported_entity->toArray());
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue