updated core to 8.6.1 via composer
This commit is contained in:
@@ -18,6 +18,11 @@ class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
|
||||
* 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'])) {
|
||||
|
||||
@@ -55,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',
|
||||
@@ -100,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);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
|
||||
/**
|
||||
* The configuration manager.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface;
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface
|
||||
*/
|
||||
protected $configManager;
|
||||
|
||||
@@ -395,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 {
|
||||
@@ -416,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;
|
||||
@@ -64,7 +65,7 @@ class ConfigSync extends FormBase {
|
||||
/**
|
||||
* The configuration manager.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface;
|
||||
* @var \Drupal\Core\Config\ConfigManagerInterface
|
||||
*/
|
||||
protected $configManager;
|
||||
|
||||
@@ -191,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;
|
||||
}
|
||||
@@ -214,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +296,7 @@ class ConfigSync extends FormBase {
|
||||
'class' => ['use-ajax'],
|
||||
'data-dialog-type' => 'modal',
|
||||
'data-dialog-options' => json_encode([
|
||||
'width' => 700
|
||||
'width' => 700,
|
||||
]),
|
||||
],
|
||||
];
|
||||
@@ -330,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_collection_install_test
|
||||
- drupal:config_collection_install_test
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
collection: another_collection
|
||||
collection: another_collection
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
collection: collection.test1
|
||||
collection: collection.test1
|
||||
|
||||
+1
-1
@@ -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',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -40,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;
|
||||
}
|
||||
|
||||
+7
@@ -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
|
||||
+1
-1
@@ -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
|
||||
|
||||
+11
@@ -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
|
||||
+2
-2
@@ -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
|
||||
|
||||
-13
@@ -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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -158,6 +158,14 @@ 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'
|
||||
|
||||
@@ -138,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'));
|
||||
|
||||
@@ -74,8 +74,11 @@ class ConfigValidation {
|
||||
* The validation execution context.
|
||||
*/
|
||||
public static function validateMapping($mapping, ExecutionContextInterface $context) {
|
||||
if ($diff = array_diff(array_keys($mapping), ['llama', 'cat', 'giraffe', 'uuid', '_core'])) {
|
||||
$context->addViolation('Missing giraffe.');
|
||||
// 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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,17 @@ 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}
|
||||
*/
|
||||
|
||||
+30
@@ -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';
|
||||
|
||||
}
|
||||
+35
@@ -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';
|
||||
|
||||
}
|
||||
+35
@@ -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';
|
||||
|
||||
}
|
||||
+24
@@ -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';
|
||||
|
||||
}
|
||||
+34
@@ -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';
|
||||
|
||||
}
|
||||
+29
@@ -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';
|
||||
|
||||
}
|
||||
+73
@@ -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.
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -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';
|
||||
|
||||
}
|
||||
+36
@@ -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';
|
||||
|
||||
}
|
||||
+31
@@ -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';
|
||||
|
||||
}
|
||||
+5
@@ -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
|
||||
|
||||
@@ -243,7 +243,7 @@ class ConfigEntityListTest extends BrowserTestBase {
|
||||
$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.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
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;
|
||||
@@ -147,7 +147,7 @@ class ConfigEntityTest extends BrowserTestBase {
|
||||
]);
|
||||
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()),
|
||||
]));
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class ConfigEntityTest extends BrowserTestBase {
|
||||
]);
|
||||
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()),
|
||||
]));
|
||||
}
|
||||
@@ -175,13 +175,13 @@ class ConfigEntityTest extends BrowserTestBase {
|
||||
]);
|
||||
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,
|
||||
]));
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
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;
|
||||
@@ -102,7 +101,7 @@ class ConfigExportImportUITest extends BrowserTestBase {
|
||||
$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 BrowserTestBase {
|
||||
|
||||
// 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 BrowserTestBase {
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
namespace Drupal\Tests\config\Functional;
|
||||
|
||||
use Drupal\Core\Config\StorageComparer;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
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;
|
||||
|
||||
@@ -72,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.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
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\Tests\BrowserTestBase;
|
||||
|
||||
@@ -433,7 +433,7 @@ class ConfigImportUITest extends BrowserTestBase {
|
||||
|
||||
// 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.'));
|
||||
@@ -518,4 +518,17 @@ class ConfigImportUITest extends BrowserTestBase {
|
||||
$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.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase {
|
||||
*/
|
||||
protected $profile = 'testing_config_overrides';
|
||||
|
||||
|
||||
/**
|
||||
* Tests install profile config changes.
|
||||
*/
|
||||
|
||||
+35
-38
@@ -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>');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -177,7 +177,7 @@ EOD;
|
||||
// object.
|
||||
$this->assertRaw(t('Are you sure you want to update the %name @type?', [
|
||||
'%name' => 'second',
|
||||
'@type' => 'test configuration'
|
||||
'@type' => 'test configuration',
|
||||
]));
|
||||
$this->drupalPostForm(NULL, [], t('Confirm'));
|
||||
$entity = $storage->load('second');
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace Drupal\Tests\config\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the Config operations through the UI.
|
||||
*
|
||||
* @group config
|
||||
*/
|
||||
class ConfigEntityTest extends JavascriptTestBase {
|
||||
class ConfigEntityTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
@@ -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 mopdule 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'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user