Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -15,19 +15,19 @@ function config_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.config':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the <a href=":url">online documentation for the Configuration Manager module</a>.', array(':url' => 'https://www.drupal.org/documentation/administer/config')) . '</p>';
$output .= '<p>' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the <a href=":url">online documentation for the Configuration Manager module</a>.', [':url' => 'https://www.drupal.org/documentation/administer/config']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Exporting the full configuration') . '</dt>';
$output .= '<dd>' . t('You can create and download an archive consisting of all your site\'s configuration exported as <em>*.yml</em> files on the <a href=":url">Export</a> page.', array(':url' => \Drupal::url('config.export_full'))) . '</dd>';
$output .= '<dd>' . t('You can create and download an archive consisting of all your site\'s configuration exported as <em>*.yml</em> files on the <a href=":url">Export</a> page.', [':url' => \Drupal::url('config.export_full')]) . '</dd>';
$output .= '<dt>' . t('Importing a full configuration') . '</dt>';
$output .= '<dd>' . t('You can upload a full site configuration from an archive file on the <a href=":url">Import</a> page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the <em>system.site</em> configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', array(':url' => \Drupal::url('config.import_full'))) . '</dd>';
$output .= '<dd>' . t('You can upload a full site configuration from an archive file on the <a href=":url">Import</a> page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the <em>system.site</em> configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', [':url' => \Drupal::url('config.import_full')]) . '</dd>';
$output .= '<dt>' . t('Synchronizing configuration') . '</dt>';
$output .= '<dd>' . t('You can review differences between the active configuration and an imported configuration archive on the <a href=":synchronize">Synchronize</a> page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', array(':synchronize' => \Drupal::url('config.sync'))) . '</dd>';
$output .= '<dd>' . t('You can review differences between the active configuration and an imported configuration archive on the <a href=":synchronize">Synchronize</a> page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', [':synchronize' => \Drupal::url('config.sync')]) . '</dd>';
$output .= '<dt>' . t('Exporting a single configuration item') . '</dt>';
$output .= '<dd>' . t('You can export a single configuration item by selecting a <em>Configuration type</em> and <em>Configuration name</em> on the <a href=":single-export">Single export</a> page. The configuration and its corresponding <em>*.yml file name</em> are then displayed on the page for you to copy.', array(':single-export' => \Drupal::url('config.export_single'))) . '</dd>';
$output .= '<dd>' . t('You can export a single configuration item by selecting a <em>Configuration type</em> and <em>Configuration name</em> on the <a href=":single-export">Single export</a> page. The configuration and its corresponding <em>*.yml file name</em> are then displayed on the page for you to copy.', [':single-export' => \Drupal::url('config.export_single')]) . '</dd>';
$output .= '<dt>' . t('Importing a single configuration item') . '</dt>';
$output .= '<dd>' . t('You can import a single configuration item by pasting it in YAML format into the form on the <a href=":single-import">Single import</a> page.', array(':single-import' => \Drupal::url('config.import_single'))) . '</dd>';
$output .= '<dd>' . t('You can import a single configuration item by pasting it in YAML format into the form on the <a href=":single-import">Single import</a> page.', [':single-import' => \Drupal::url('config.import_single')]) . '</dd>';
$output .= '</dl>';
return $output;
@ -72,9 +72,9 @@ function config_file_download($uri) {
$hostname = str_replace('.', '-', $request->getHttpHost());
$filename = 'config' . '-' . $hostname . '-' . $date_string . '.tar.gz';
$disposition = 'attachment; filename="' . $filename . '"';
return array(
return [
'Content-disposition' => $disposition,
);
];
}
return -1;
}

View file

@ -29,8 +29,8 @@ class ConfigSubscriber extends ConfigImportValidateEventSubscriberBase {
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20);
public static function getSubscribedEvents() {
$events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20];
return $events;
}

View file

@ -103,7 +103,7 @@ class ConfigController implements ContainerInjectionInterface {
}
}
$request = new Request(array('file' => 'config.tar.gz'));
$request = new Request(['file' => 'config.tar.gz']);
return $this->fileDownloadController->download($request, 'temporary');
}
@ -129,34 +129,34 @@ class ConfigController implements ContainerInjectionInterface {
$diff = $this->configManager->diff($this->targetStorage, $this->sourceStorage, $source_name, $target_name, $collection);
$this->diffFormatter->show_header = FALSE;
$build = array();
$build = [];
$build['#title'] = t('View changes of @config_file', array('@config_file' => $source_name));
$build['#title'] = t('View changes of @config_file', ['@config_file' => $source_name]);
// Add the CSS for the inline diff.
$build['#attached']['library'][] = 'system/diff';
$build['diff'] = array(
$build['diff'] = [
'#type' => 'table',
'#attributes' => array(
'class' => array('diff'),
),
'#header' => array(
array('data' => t('Active'), 'colspan' => '2'),
array('data' => t('Staged'), 'colspan' => '2'),
),
'#attributes' => [
'class' => ['diff'],
],
'#header' => [
['data' => t('Active'), 'colspan' => '2'],
['data' => t('Staged'), 'colspan' => '2'],
],
'#rows' => $this->diffFormatter->format($diff),
);
];
$build['back'] = array(
$build['back'] = [
'#type' => 'link',
'#attributes' => array(
'class' => array(
'#attributes' => [
'class' => [
'dialog-cancel',
),
),
],
],
'#title' => "Back to 'Synchronize configuration' page.",
'#url' => Url::fromRoute('config.sync'),
);
];
return $build;
}

View file

@ -21,10 +21,10 @@ class ConfigExportForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['submit'] = array(
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Export'),
);
];
return $form;
}

View file

@ -55,17 +55,17 @@ class ConfigImportForm extends FormBase {
if (!$directory_is_writable) {
drupal_set_message($this->t('The directory %directory is not writable.', ['%directory' => $directory]), 'error');
}
$form['import_tarball'] = array(
$form['import_tarball'] = [
'#type' => 'file',
'#title' => $this->t('Configuration archive'),
'#description' => $this->t('Allowed types: @extensions.', array('@extensions' => 'tar.gz tgz tar.bz2')),
);
'#description' => $this->t('Allowed types: @extensions.', ['@extensions' => 'tar.gz tgz tar.bz2']),
];
$form['submit'] = array(
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Upload'),
'#disabled' => !$directory_is_writable,
);
];
return $form;
}
@ -93,7 +93,7 @@ class ConfigImportForm extends FormBase {
$this->configStorage->deleteAll();
try {
$archiver = new ArchiveTar($path, 'gz');
$files = array();
$files = [];
foreach ($archiver->listContent() as $file) {
$files[] = $file['filename'];
}
@ -102,7 +102,7 @@ class ConfigImportForm extends FormBase {
$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>', array('@message' => $e->getMessage())), 'error');
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');
}
drupal_unlink($path);
}

View file

@ -2,6 +2,7 @@
namespace Drupal\config\Form;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
@ -36,7 +37,7 @@ class ConfigSingleExportForm extends FormBase {
*
* @var \Drupal\Core\Entity\EntityTypeInterface[]
*/
protected $definitions = array();
protected $definitions = [];
/**
* Constructs a new ConfigSingleImportForm.
@ -73,7 +74,7 @@ class ConfigSingleExportForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) {
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($definition->entityClassImplements(ConfigEntityInterface::class)) {
$this->definitions[$entity_type] = $definition;
}
}
@ -82,40 +83,40 @@ class ConfigSingleExportForm extends FormBase {
}, $this->definitions);
// Sort the entity types by label, then add the simple config to the top.
uasort($entity_types, 'strnatcasecmp');
$config_types = array(
$config_types = [
'system.simple' => $this->t('Simple configuration'),
) + $entity_types;
$form['config_type'] = array(
] + $entity_types;
$form['config_type'] = [
'#title' => $this->t('Configuration type'),
'#type' => 'select',
'#options' => $config_types,
'#default_value' => $config_type,
'#ajax' => array(
'#ajax' => [
'callback' => '::updateConfigurationType',
'wrapper' => 'edit-config-type-wrapper',
),
);
],
];
$default_type = $form_state->getValue('config_type', $config_type);
$form['config_name'] = array(
$form['config_name'] = [
'#title' => $this->t('Configuration name'),
'#type' => 'select',
'#options' => $this->findConfiguration($default_type),
'#default_value' => $config_name,
'#prefix' => '<div id="edit-config-type-wrapper">',
'#suffix' => '</div>',
'#ajax' => array(
'#ajax' => [
'callback' => '::updateExport',
'wrapper' => 'edit-export-wrapper',
),
);
],
];
$form['export'] = array(
$form['export'] = [
'#title' => $this->t('Here is your configuration:'),
'#type' => 'textarea',
'#rows' => 24,
'#prefix' => '<div id="edit-export-wrapper">',
'#suffix' => '</div>',
);
];
if ($config_type && $config_name) {
$fake_form_state = (new FormState())->setValues([
'config_type' => $config_type,
@ -149,7 +150,7 @@ class ConfigSingleExportForm extends FormBase {
}
// Read the raw data for this config name, encode it, and display it.
$form['export']['#value'] = Yaml::encode($this->configStorage->read($name));
$form['export']['#description'] = $this->t('Filename: %name', array('%name' => $name . '.yml'));
$form['export']['#description'] = $this->t('Filename: %name', ['%name' => $name . '.yml']);
return $form['export'];
}
@ -157,9 +158,9 @@ class ConfigSingleExportForm extends FormBase {
* Handles switching the configuration type selector.
*/
protected function findConfiguration($config_type) {
$names = array(
$names = [
'' => $this->t('- Select -'),
);
];
// For a given entity type, load all entities.
if ($config_type && $config_type !== 'system.simple') {
$entity_storage = $this->entityManager->getStorage($config_type);

View file

@ -7,6 +7,7 @@ use Drupal\config\StorageReplaceDataWrapper;
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Config\ConfigManagerInterface;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\StorageComparer;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
@ -110,7 +111,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
*
* @var array
*/
protected $data = array();
protected $data = [];
/**
* Constructs a new ConfigSingleImportForm.
@ -197,10 +198,10 @@ class ConfigSingleImportForm extends ConfirmFormBase {
$type = $definition->getLowercaseLabel();
}
$args = array(
$args = [
'%name' => $name,
'@type' => strtolower($type),
);
];
if ($this->configExists) {
$question = $this->t('Are you sure you want to update the %name @type?', $args);
}
@ -219,57 +220,57 @@ class ConfigSingleImportForm extends ConfirmFormBase {
return parent::buildForm($form, $form_state);
}
$entity_types = array();
$entity_types = [];
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
if ($definition->entityClassImplements(ConfigEntityInterface::class)) {
$entity_types[$entity_type] = $definition->getLabel();
}
}
// Sort the entity types by label, then add the simple config to the top.
uasort($entity_types, 'strnatcasecmp');
$config_types = array(
$config_types = [
'system.simple' => $this->t('Simple configuration'),
) + $entity_types;
$form['config_type'] = array(
] + $entity_types;
$form['config_type'] = [
'#title' => $this->t('Configuration type'),
'#type' => 'select',
'#options' => $config_types,
'#required' => TRUE,
);
$form['config_name'] = array(
];
$form['config_name'] = [
'#title' => $this->t('Configuration name'),
'#description' => $this->t('Enter the name of the configuration file without the <em>.yml</em> extension. (e.g. <em>system.site</em>)'),
'#type' => 'textfield',
'#states' => array(
'required' => array(
':input[name="config_type"]' => array('value' => 'system.simple'),
),
'visible' => array(
':input[name="config_type"]' => array('value' => 'system.simple'),
),
),
);
$form['import'] = array(
'#states' => [
'required' => [
':input[name="config_type"]' => ['value' => 'system.simple'],
],
'visible' => [
':input[name="config_type"]' => ['value' => 'system.simple'],
],
],
];
$form['import'] = [
'#title' => $this->t('Paste your configuration here'),
'#type' => 'textarea',
'#rows' => 24,
'#required' => TRUE,
);
$form['advanced'] = array(
];
$form['advanced'] = [
'#type' => 'details',
'#title' => $this->t('Advanced'),
);
$form['advanced']['custom_entity_id'] = array(
];
$form['advanced']['custom_entity_id'] = [
'#title' => $this->t('Custom Entity ID'),
'#type' => 'textfield',
'#description' => $this->t('Specify a custom entity ID. This will override the entity ID in the configuration above.'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
];
$form['actions'] = ['#type' => 'actions'];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Import'),
'#button_type' => 'primary',
);
];
return $form;
}
@ -304,7 +305,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
$entity_storage = $this->entityManager->getStorage($form_state->getValue('config_type'));
// If an entity ID was not specified, set an error.
if (!isset($data[$id_key])) {
$form_state->setErrorByName('import', $this->t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => $id_key, '@entity_type' => $definition->getLabel())));
$form_state->setErrorByName('import', $this->t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => $id_key, '@entity_type' => $definition->getLabel()]));
return;
}
@ -322,7 +323,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
}
}
// If there is no entity with a matching ID, check for a UUID match.
elseif (isset($data['uuid']) && $entity_storage->loadByProperties(array('uuid' => $data['uuid']))) {
elseif (isset($data['uuid']) && $entity_storage->loadByProperties(['uuid' => $data['uuid']])) {
$form_state->setErrorByName('import', $this->t('An entity with this UUID already exists but the machine name does not match.'));
}
}

View file

@ -171,20 +171,20 @@ class ConfigSync extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
$form['actions'] = ['#type' => 'actions'];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Import all'),
);
];
$source_list = $this->syncStorage->listAll();
$storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, $this->configManager);
if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) {
$form['no_changes'] = array(
$form['no_changes'] = [
'#type' => 'table',
'#header' => array($this->t('Name'), $this->t('Operations')),
'#rows' => array(),
'#header' => [$this->t('Name'), $this->t('Operations')],
'#rows' => [],
'#empty' => $this->t('There are no configuration changes to import.'),
);
];
$form['actions']['#access'] = FALSE;
return $form;
}
@ -198,7 +198,7 @@ class ConfigSync extends FormBase {
if ($this->snapshotStorage->exists('core.extension')) {
$snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager);
if (!$form_state->getUserInput() && $snapshot_comparer->createChangelist()->hasChanges()) {
$change_list = array();
$change_list = [];
foreach ($snapshot_comparer->getAllCollectionNames() as $collection) {
foreach ($snapshot_comparer->getChangelist(NULL, $collection) as $config_names) {
if (empty($config_names)) {
@ -231,11 +231,11 @@ class ConfigSync extends FormBase {
foreach ($storage_comparer->getAllCollectionNames() as $collection) {
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
$form[$collection]['collection_heading'] = array(
$form[$collection]['collection_heading'] = [
'#type' => 'html_tag',
'#tag' => 'h2',
'#value' => $this->t('@collection configuration collection', array('@collection' => $collection)),
);
'#value' => $this->t('@collection configuration collection', ['@collection' => $collection]),
];
}
foreach ($storage_comparer->getChangelist(NULL, $collection) as $config_change_type => $config_names) {
if (empty($config_names)) {
@ -244,10 +244,10 @@ class ConfigSync extends FormBase {
// @todo A table caption would be more appropriate, but does not have the
// visual importance of a heading.
$form[$collection][$config_change_type]['heading'] = array(
$form[$collection][$config_change_type]['heading'] = [
'#type' => 'html_tag',
'#tag' => 'h3',
);
];
switch ($config_change_type) {
case 'create':
$form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count new', '@count new');
@ -265,19 +265,19 @@ class ConfigSync extends FormBase {
$form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count renamed', '@count renamed');
break;
}
$form[$collection][$config_change_type]['list'] = array(
$form[$collection][$config_change_type]['list'] = [
'#type' => 'table',
'#header' => array($this->t('Name'), $this->t('Operations')),
);
'#header' => [$this->t('Name'), $this->t('Operations')],
];
foreach ($config_names as $config_name) {
if ($config_change_type == 'rename') {
$names = $storage_comparer->extractRenameNames($config_name);
$route_options = array('source_name' => $names['old_name'], 'target_name' => $names['new_name']);
$config_name = $this->t('@source_name to @target_name', array('@source_name' => $names['old_name'], '@target_name' => $names['new_name']));
$route_options = ['source_name' => $names['old_name'], 'target_name' => $names['new_name']];
$config_name = $this->t('@source_name to @target_name', ['@source_name' => $names['old_name'], '@target_name' => $names['new_name']]);
}
else {
$route_options = array('source_name' => $config_name);
$route_options = ['source_name' => $config_name];
}
if ($collection != StorageInterface::DEFAULT_COLLECTION) {
$route_name = 'config.diff_collection';
@ -286,26 +286,26 @@ class ConfigSync extends FormBase {
else {
$route_name = 'config.diff';
}
$links['view_diff'] = array(
$links['view_diff'] = [
'title' => $this->t('View differences'),
'url' => Url::fromRoute($route_name, $route_options),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode(array(
'data-dialog-options' => json_encode([
'width' => 700
)),
),
);
$form[$collection][$config_change_type]['list']['#rows'][] = array(
]),
],
];
$form[$collection][$config_change_type]['list']['#rows'][] = [
'name' => $config_name,
'operations' => array(
'data' => array(
'operations' => [
'data' => [
'#type' => 'operations',
'#links' => $links,
),
),
);
],
],
];
}
}
}
@ -333,17 +333,17 @@ class ConfigSync extends FormBase {
else {
try {
$sync_steps = $config_importer->initialize();
$batch = array(
'operations' => array(),
'finished' => array(get_class($this), 'finishBatch'),
$batch = [
'operations' => [],
'finished' => [get_class($this), 'finishBatch'],
'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'][] = array(array(get_class($this), 'processBatch'), array($config_importer, $sync_step));
$batch['operations'][] = [[get_class($this), 'processBatch'], [$config_importer, $sync_step]];
}
batch_set($batch);
@ -377,7 +377,7 @@ class ConfigSync extends FormBase {
$config_importer->doSyncStep($sync_step, $context);
if ($errors = $config_importer->getErrors()) {
if (!isset($context['results']['errors'])) {
$context['results']['errors'] = array();
$context['results']['errors'] = [];
}
$context['results']['errors'] += $errors;
}
@ -406,7 +406,7 @@ class ConfigSync extends FormBase {
// 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', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)));
$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');
}
}

View file

@ -14,7 +14,7 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('config_test');
public static $modules = ['config_test'];
/**
* Tests that overrides do not affect forms or listing screens.
@ -29,10 +29,10 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
// Set up an override.
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array(
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
'value' => $overridden_label,
'required' => TRUE,
);
];
$this->writeSettings($settings);
// Test that the overridden label is loaded with the entity.
@ -50,9 +50,9 @@ class ConfigEntityFormOverrideTest extends WebTestBase {
$this->assertNoText($overridden_label);
// Change to a new label and test that the listing now has the edited label.
$edit = array(
$edit = [
'label' => $edited_label,
);
];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->drupalGet('admin/structure/config_test');
$this->assertNoText($overridden_label);

View file

@ -34,7 +34,7 @@ class ConfigEntityListTest extends WebTestBase {
/**
* Tests entity list builder methods.
*/
function testList() {
public function testList() {
$controller = \Drupal::entityManager()->getListBuilder('config_test');
// Test getStorage() method.
@ -50,71 +50,71 @@ class ConfigEntityListTest extends WebTestBase {
$this->assertTrue($entity instanceof ConfigTest, '"Default" ConfigTest entity is an instance of ConfigTest.');
// Test getOperations() method.
$expected_operations = array(
'edit' => array (
$expected_operations = [
'edit' => [
'title' => t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo(),
),
'disable' => array(
],
'disable' => [
'title' => t('Disable'),
'weight' => 40,
'url' => $entity->urlInfo('disable'),
),
'delete' => array (
],
'delete' => [
'title' => t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo('delete-form'),
),
);
],
];
$actual_operations = $controller->getOperations($entity);
// Sort the operations to normalize link order.
uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
uasort($actual_operations, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
$this->assertEqual($expected_operations, $actual_operations, 'The operations are identical.');
// Test buildHeader() method.
$expected_items = array(
$expected_items = [
'label' => 'Label',
'id' => 'Machine name',
'operations' => 'Operations',
);
];
$actual_items = $controller->buildHeader();
$this->assertEqual($expected_items, $actual_items, 'Return value from buildHeader matches expected.');
// Test buildRow() method.
$build_operations = $controller->buildOperations($entity);
$expected_items = array(
$expected_items = [
'label' => 'Default',
'id' => 'dotted.default',
'operations' => array(
'operations' => [
'data' => $build_operations,
),
);
],
];
$actual_items = $controller->buildRow($entity);
$this->assertEqual($expected_items, $actual_items, 'Return value from buildRow matches expected.');
// Test sorting.
$storage = $controller->getStorage();
$entity = $storage->create(array(
$entity = $storage->create([
'id' => 'alpha',
'label' => 'Alpha',
'weight' => 1,
));
]);
$entity->save();
$entity = $storage->create(array(
$entity = $storage->create([
'id' => 'omega',
'label' => 'Omega',
'weight' => 1,
));
]);
$entity->save();
$entity = $storage->create(array(
$entity = $storage->create([
'id' => 'beta',
'label' => 'Beta',
'weight' => 0,
));
]);
$entity->save();
$list = $controller->load();
$this->assertIdentical(array_keys($list), array('beta', 'dotted.default', 'alpha', 'omega'));
$this->assertIdentical(array_keys($list), ['beta', 'dotted.default', 'alpha', 'omega']);
// Test that config entities that do not support status, do not have
// enable/disable operations.
@ -125,31 +125,31 @@ class ConfigEntityListTest extends WebTestBase {
$entity = $list['default'];
// Test getOperations() method.
$expected_operations = array(
'edit' => array(
$expected_operations = [
'edit' => [
'title' => t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo(),
),
'delete' => array(
],
'delete' => [
'title' => t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo('delete-form'),
),
);
],
];
$actual_operations = $controller->getOperations($entity);
// Sort the operations to normalize link order.
uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
uasort($actual_operations, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
$this->assertEqual($expected_operations, $actual_operations, 'The operations are identical.');
}
/**
* Tests the listing UI.
*/
function testListUI() {
public function testListUI() {
// Log in as an administrative user to access the full menu trail.
$this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration')));
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
// Get the list callback page.
$this->drupalGet('admin/structure/config_test');
@ -166,7 +166,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->assertEqual(count($elements), 3, 'Correct number of table header cells found.');
// Test the contents of each th cell.
$expected_items = array('Label', 'Machine name', 'Operations');
$expected_items = ['Label', 'Machine name', 'Operations'];
foreach ($elements as $key => $element) {
$this->assertIdentical((string) $element[0], $expected_items[$key]);
}
@ -186,11 +186,11 @@ class ConfigEntityListTest extends WebTestBase {
$this->assertLink('Add test configuration');
$this->clickLink('Add test configuration');
$this->assertResponse(200);
$edit = array(
$edit = [
'label' => 'Antelope',
'id' => 'antelope',
'weight' => 1,
);
];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Ensure that the entity's sort method was called.
@ -207,7 +207,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->clickLink('Edit', 1);
$this->assertResponse(200);
$this->assertTitle('Edit Antelope | Drupal');
$edit = array('label' => 'Albatross', 'id' => 'albatross');
$edit = ['label' => 'Albatross', 'id' => 'albatross'];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Confirm that the user is returned to the listing, and verify that the
@ -221,7 +221,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->clickLink('Delete', 1);
$this->assertResponse(200);
$this->assertTitle('Are you sure you want to delete the test configuration Albatross? | Drupal');
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalPostForm(NULL, [], t('Delete'));
// Verify that the text of the label and machine name does not appear in
// the list (though it may appear elsewhere on the page).
@ -232,7 +232,7 @@ class ConfigEntityListTest extends WebTestBase {
$this->clickLink('Delete');
$this->assertResponse(200);
$this->assertTitle('Are you sure you want to delete the test configuration Default? | Drupal');
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalPostForm(NULL, [], t('Delete'));
// Verify that the text of the label and machine name does not appear in
// the list (though it may appear elsewhere on the page).
@ -253,12 +253,12 @@ class ConfigEntityListTest extends WebTestBase {
// Create 51 test entities.
for ($i = 1; $i < 52; $i++) {
$storage->create(array(
$storage->create([
'id' => str_pad($i, 2, '0', STR_PAD_LEFT),
'label' => 'Test config entity ' . $i,
'weight' => $i,
'protected_property' => $i,
))->save();
])->save();
}
// Load the listing page.

View file

@ -27,12 +27,12 @@ class ConfigEntityTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config_test');
public static $modules = ['config_test'];
/**
* Tests CRUD operations.
*/
function testCRUD() {
public function testCRUD() {
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
// Verify default properties on a newly created empty entity.
$empty = entity_create('config_test');
@ -76,9 +76,9 @@ class ConfigEntityTest extends WebTestBase {
}
// Verify that an entity with an empty ID string is considered empty, too.
$empty_id = entity_create('config_test', array(
$empty_id = entity_create('config_test', [
'id' => '',
));
]);
$this->assertIdentical($empty_id->isNew(), TRUE);
try {
$empty_id->save();
@ -89,11 +89,11 @@ class ConfigEntityTest extends WebTestBase {
}
// Verify properties on a newly created entity.
$config_test = entity_create('config_test', $expected = array(
$config_test = entity_create('config_test', $expected = [
'id' => $this->randomMachineName(),
'label' => $this->randomString(),
'style' => $this->randomMachineName(),
));
]);
$this->assertTrue($config_test->uuid());
$this->assertNotEqual($config_test->uuid(), $empty->uuid());
$this->assertIdentical($config_test->label, $expected['label']);
@ -141,13 +141,13 @@ class ConfigEntityTest extends WebTestBase {
// maximum allowed length, but not longer.
// Test with a short ID.
$id_length_config_test = entity_create('config_test', array(
$id_length_config_test = entity_create('config_test', [
'id' => $this->randomMachineName(8),
));
]);
try {
$id_length_config_test->save();
$this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array(
'@length' => strlen($id_length_config_test->id()))
$this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [
'@length' => strlen($id_length_config_test->id())]
));
}
catch (ConfigEntityIdLengthException $e) {
@ -155,42 +155,42 @@ class ConfigEntityTest extends WebTestBase {
}
// Test with an ID of the maximum allowed length.
$id_length_config_test = entity_create('config_test', array(
$id_length_config_test = entity_create('config_test', [
'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.", array(
$this->pass(SafeMarkup::format("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 exceeding the maximum allowed length.
$id_length_config_test = entity_create('config_test', array(
$id_length_config_test = entity_create('config_test', [
'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", array(
$this->fail(SafeMarkup::format("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", array(
$this->pass(SafeMarkup::format("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,
)));
]));
}
// Ensure that creating an entity with the same id as an existing one is not
// possible.
$same_id = entity_create('config_test', array(
$same_id = entity_create('config_test', [
'id' => $config_test->id(),
));
]);
$this->assertIdentical($same_id->isNew(), TRUE);
try {
$same_id->save();
@ -201,7 +201,7 @@ class ConfigEntityTest extends WebTestBase {
}
// Verify that renaming the ID returns correct status and properties.
$ids = array($expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4));
$ids = [$expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4)];
for ($i = 1; $i < 3; $i++) {
$old_id = $ids[$i - 1];
$new_id = $ids[$i];
@ -223,29 +223,29 @@ class ConfigEntityTest extends WebTestBase {
// Test config entity prepopulation.
\Drupal::state()->set('config_test.prepopulate', TRUE);
$config_test = entity_create('config_test', array('foo' => 'bar'));
$config_test = entity_create('config_test', ['foo' => 'bar']);
$this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated');
}
/**
* Tests CRUD operations through the UI.
*/
function testCRUDUI() {
public function testCRUDUI() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$id = strtolower($this->randomMachineName());
$label1 = $this->randomMachineName();
$label2 = $this->randomMachineName();
$label3 = $this->randomMachineName();
$message_insert = format_string('%label configuration has been created.', array('%label' => $label1));
$message_update = format_string('%label configuration has been updated.', array('%label' => $label2));
$message_delete = format_string('The test configuration %label has been deleted.', array('%label' => $label2));
$message_insert = format_string('%label configuration has been created.', ['%label' => $label1]);
$message_update = format_string('%label configuration has been updated.', ['%label' => $label2]);
$message_delete = format_string('The test configuration %label has been deleted.', ['%label' => $label2]);
// Create a configuration entity.
$edit = array(
$edit = [
'id' => $id,
'label' => $label1,
);
];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@ -254,9 +254,9 @@ class ConfigEntityTest extends WebTestBase {
$this->assertLinkByHref("admin/structure/config_test/manage/$id");
// Update the configuration entity.
$edit = array(
$edit = [
'label' => $label2,
);
];
$this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@ -269,7 +269,7 @@ class ConfigEntityTest extends WebTestBase {
$this->drupalGet("admin/structure/config_test/manage/$id");
$this->clickLink(t('Delete'));
$this->assertUrl("admin/structure/config_test/manage/$id/delete");
$this->drupalPostForm(NULL, array(), 'Delete');
$this->drupalPostForm(NULL, [], 'Delete');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
$this->assertNoRaw($message_update);
@ -278,10 +278,10 @@ class ConfigEntityTest extends WebTestBase {
$this->assertNoLinkByHref("admin/structure/config_test/manage/$id");
// Re-create a configuration entity.
$edit = array(
$edit = [
'id' => $id,
'label' => $label1,
);
];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@ -289,10 +289,10 @@ class ConfigEntityTest extends WebTestBase {
$this->assertLinkByHref("admin/structure/config_test/manage/$id");
// Rename the configuration entity's ID/machine name.
$edit = array(
$edit = [
'id' => strtolower($this->randomMachineName()),
'label' => $label3,
);
];
$this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save');
$this->assertUrl('admin/structure/config_test');
$this->assertResponse(200);
@ -304,17 +304,17 @@ class ConfigEntityTest extends WebTestBase {
$this->assertLinkByHref("admin/structure/config_test/manage/$id");
// Create a configuration entity with '0' machine name.
$edit = array(
$edit = [
'id' => '0',
'label' => '0',
);
];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$this->assertResponse(200);
$message_insert = format_string('%label configuration has been created.', array('%label' => $edit['label']));
$message_insert = format_string('%label configuration has been created.', ['%label' => $edit['label']]);
$this->assertRaw($message_insert);
$this->assertLinkByHref('admin/structure/config_test/manage/0');
$this->assertLinkByHref('admin/structure/config_test/manage/0/delete');
$this->drupalPostForm('admin/structure/config_test/manage/0/delete', array(), 'Delete');
$this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete');
$this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted');
// Create a configuration entity with a property that uses AJAX to show

View file

@ -67,7 +67,7 @@ class ConfigExportImportUITest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config', 'node', 'field');
public static $modules = ['config', 'node', 'field'];
/**
* {@inheritdoc}
@ -103,11 +103,11 @@ class ConfigExportImportUITest extends WebTestBase {
// Create a field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
$this->fieldStorage = FieldStorageConfig::create(array(
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'type' => 'text',
));
]);
$this->fieldStorage->save();
FieldConfig::create([
'field_storage' => $this->fieldStorage,
@ -116,9 +116,9 @@ class ConfigExportImportUITest extends WebTestBase {
// Update the displays so that configuration does not change unexpectedly on
// import.
entity_get_form_display('node', $this->contentType->id(), 'default')
->setComponent($this->fieldName, array(
->setComponent($this->fieldName, [
'type' => 'text_textfield',
))
])
->save();
entity_get_display('node', $this->contentType->id(), 'full')
->setComponent($this->fieldName)
@ -134,7 +134,7 @@ class ConfigExportImportUITest extends WebTestBase {
$this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
$this->tarball = $this->getRawContent();
$this->config('system.site')
@ -161,13 +161,13 @@ class ConfigExportImportUITest extends WebTestBase {
// Import the configuration.
$filename = 'temporary://' . $this->randomMachineName();
file_put_contents($filename, $this->tarball);
$this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload');
$this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload');
// There is no snapshot yet because an import has never run.
$this->assertNoText(t('Warning message'));
$this->assertNoText(t('There are no configuration changes to import.'));
$this->assertText($this->contentType->label());
$this->drupalPostForm(NULL, array(), 'Import all');
$this->drupalPostForm(NULL, [], 'Import all');
// After importing the snapshot has been updated an there are no warnings.
$this->assertNoText(t('Warning message'));
$this->assertText(t('There are no configuration changes to import.'));
@ -217,25 +217,25 @@ class ConfigExportImportUITest extends WebTestBase {
/** @var \Drupal\Core\Config\StorageInterface $active_storage */
$active_storage = \Drupal::service('config.storage');
$test1_storage = $active_storage->createCollection('collection.test1');
$test1_storage->write('config_test.create', array('foo' => 'bar'));
$test1_storage->write('config_test.update', array('foo' => 'bar'));
$test1_storage->write('config_test.create', ['foo' => 'bar']);
$test1_storage->write('config_test.update', ['foo' => 'bar']);
$test2_storage = $active_storage->createCollection('collection.test2');
$test2_storage->write('config_test.another_create', array('foo' => 'bar'));
$test2_storage->write('config_test.another_update', array('foo' => 'bar'));
$test2_storage->write('config_test.another_create', ['foo' => 'bar']);
$test2_storage->write('config_test.another_update', ['foo' => 'bar']);
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
$this->tarball = $this->getRawContent();
$filename = file_directory_temp() . '/' . $this->randomMachineName();
file_put_contents($filename, $this->tarball);
// Set up the active storage collections to test import.
$test1_storage->delete('config_test.create');
$test1_storage->write('config_test.update', array('foo' => 'baz'));
$test1_storage->write('config_test.delete', array('foo' => 'bar'));
$test1_storage->write('config_test.update', ['foo' => 'baz']);
$test1_storage->write('config_test.delete', ['foo' => 'bar']);
$test2_storage->delete('config_test.another_create');
$test2_storage->write('config_test.another_update', array('foo' => 'baz'));
$test2_storage->write('config_test.another_delete', array('foo' => 'bar'));
$test2_storage->write('config_test.another_update', ['foo' => 'baz']);
$test2_storage->write('config_test.another_delete', ['foo' => 'bar']);
// Create a snapshot.
$snapshot_storage = \Drupal::service('config.storage.snapshot');
@ -244,22 +244,22 @@ class ConfigExportImportUITest extends WebTestBase {
// Ensure that the snapshot has the expected collection data before import.
$test1_snapshot = $snapshot_storage->createCollection('collection.test1');
$data = $test1_snapshot->read('config_test.delete');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.delete in collection.test1 exists in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.delete in collection.test1 exists in the snapshot storage.');
$data = $test1_snapshot->read('config_test.update');
$this->assertEqual($data, array('foo' => 'baz'), 'The config_test.update in collection.test1 exists in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'baz'], 'The config_test.update in collection.test1 exists in the snapshot storage.');
$this->assertFalse($test1_snapshot->read('config_test.create'), 'The config_test.create in collection.test1 does not exist in the snapshot storage.');
$test2_snapshot = $snapshot_storage->createCollection('collection.test2');
$data = $test2_snapshot->read('config_test.another_delete');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_delete in collection.test2 exists in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_delete in collection.test2 exists in the snapshot storage.');
$data = $test2_snapshot->read('config_test.another_update');
$this->assertEqual($data, array('foo' => 'baz'), 'The config_test.another_update in collection.test2 exists in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'baz'], 'The config_test.another_update in collection.test2 exists in the snapshot storage.');
$this->assertFalse($test2_snapshot->read('config_test.another_create'), 'The config_test.another_create in collection.test2 does not exist in the snapshot storage.');
// Create the tar that contains the expected content for the collections.
$tar = new ArchiveTar($filename, 'gz');
$content_list = $tar->listContent();
// Convert the list of files into something easy to search.
$files = array();
$files = [];
foreach ($content_list as $file) {
$files[] = $file['filename'];
}
@ -270,12 +270,12 @@ class ConfigExportImportUITest extends WebTestBase {
$this->assertFalse(in_array('collection/test1/config_test.delete.yml', $files), 'Config export does not contain collection/test1/config_test.delete.yml.');
$this->assertFalse(in_array('collection/test2/config_test.another_delete.yml', $files), 'Config export does not contain collection/test2/config_test.another_delete.yml.');
$this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload');
$this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload');
// Verify that there are configuration differences to import.
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
$this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test1')));
$this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test2')));
$this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test1']));
$this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test2']));
$this->assertText('config_test.create');
$this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create');
$this->assertText('config_test.update');
@ -289,35 +289,35 @@ class ConfigExportImportUITest extends WebTestBase {
$this->assertText('config_test.another_delete');
$this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete');
$this->drupalPostForm(NULL, array(), 'Import all');
$this->drupalPostForm(NULL, [], 'Import all');
$this->assertText(t('There are no configuration changes to import.'));
// Test data in collections.
$data = $test1_storage->read('config_test.create');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.create in collection.test1 has been created.');
$data = $test1_storage->read('config_test.update');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.update in collection.test1 has been updated.');
$this->assertFalse($test1_storage->read('config_test.delete'), 'The config_test.delete in collection.test1 has been deleted.');
$data = $test2_storage->read('config_test.another_create');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_create in collection.test2 has been created.');
$data = $test2_storage->read('config_test.another_update');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_update in collection.test2 has been updated.');
$this->assertFalse($test2_storage->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 has been deleted.');
// Ensure that the snapshot has been updated with the collection data.
$snapshot_storage = \Drupal::service('config.storage.snapshot');
$test1_snapshot = $snapshot_storage->createCollection('collection.test1');
$data = $test1_snapshot->read('config_test.create');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.create in collection.test1 has been created in the snapshot storage.');
$data = $test1_snapshot->read('config_test.update');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.update in collection.test1 has been updated in the snapshot storage.');
$this->assertFalse($test1_snapshot->read('config_test.delete'), 'The config_test.delete in collection.test1 does not exist in the snapshot storage.');
$test2_snapshot = $snapshot_storage->createCollection('collection.test2');
$data = $test2_snapshot->read('config_test.another_create');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_create in collection.test2 has been created in the snapshot storage.');
$data = $test2_snapshot->read('config_test.another_update');
$this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.');
$this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.');
$this->assertFalse($test2_snapshot->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 does not exist in the snapshot storage.');
}

View file

@ -18,7 +18,7 @@ class ConfigExportUITest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config', 'config_test');
public static $modules = ['config', 'config_test'];
/**
* {@inheritdoc}
@ -27,25 +27,25 @@ class ConfigExportUITest extends WebTestBase {
parent::setUp();
// Set up an override.
$settings['config']['system.maintenance']['message'] = (object) array(
$settings['config']['system.maintenance']['message'] = (object) [
'value' => 'Foo',
'required' => TRUE,
);
];
$this->writeSettings($settings);
$this->drupalLogin($this->drupalCreateUser(array('export configuration')));
$this->drupalLogin($this->drupalCreateUser(['export configuration']));
}
/**
* Tests export of configuration.
*/
function testExport() {
public function testExport() {
// Verify the export page with export submit button is available.
$this->drupalGet('admin/config/development/configuration/full/export');
$this->assertFieldById('edit-submit', t('Export'));
// Submit the export form and verify response.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
$this->drupalPostForm('admin/config/development/configuration/full/export', [], t('Export'));
$this->assertResponse(200, 'User can access the download callback.');
// Test if header contains file name with hostname and timestamp.
@ -70,7 +70,7 @@ class ConfigExportUITest extends WebTestBase {
// Prepare the list of config files from active storage, see
// \Drupal\config\Controller\ConfigController::downloadExport().
$storage_active = $this->container->get('config.storage');
$config_files = array();
$config_files = [];
foreach ($storage_active->listAll() as $config_name) {
$config_files[] = $config_name . '.yml';
}
@ -80,7 +80,7 @@ class ConfigExportUITest extends WebTestBase {
// Ensure the test configuration override is in effect but was not exported.
$this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
$archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
$archiver->extract(file_directory_temp(), ['system.maintenance.yml']);
$file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
$exported = Yaml::decode($file_contents);
$this->assertNotIdentical($exported['message'], 'Foo');

View file

@ -16,15 +16,15 @@ class ConfigFormOverrideTest extends WebTestBase {
* Tests that overrides do not affect forms.
*/
public function testFormsWithOverrides() {
$this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration')));
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$overridden_name = 'Site name global conf override';
// Set up an override.
$settings['config']['system.site']['name'] = (object) array(
$settings['config']['system.site']['name'] = (object) [
'value' => $overridden_name,
'required' => TRUE,
);
];
$this->writeSettings($settings);
// Test that everything on the form is the same, but that the override
@ -35,9 +35,9 @@ class ConfigFormOverrideTest extends WebTestBase {
$this->assertIdentical((string) $elements[0]['value'], 'Drupal');
// Submit the form and ensure the site name is not changed.
$edit = array(
$edit = [
'site_name' => 'Custom site name',
);
];
$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"]');

View file

@ -36,7 +36,7 @@ class ConfigImportAllTest extends ModuleTestBase {
protected function setUp() {
parent::setUp();
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->webUser = $this->drupalCreateUser(['synchronize configuration']);
$this->drupalLogin($this->webUser);
}
@ -124,12 +124,12 @@ class ConfigImportAllTest extends ModuleTestBase {
}
// Import the configuration thereby re-installing all the modules.
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
$this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
// Modules have been installed that have services.
$this->rebuildContainer();
// Check that there are no errors.
$this->assertIdentical($this->configImporter()->getErrors(), array());
$this->assertIdentical($this->configImporter()->getErrors(), []);
// Check that all modules that were uninstalled are now reinstalled.
$this->assertModules(array_keys($modules_to_uninstall), TRUE);

View file

@ -23,7 +23,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config');
public static $modules = ['config'];
/**
* A user with the 'synchronize configuration' permission.
@ -35,7 +35,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->webUser = $this->drupalCreateUser(['synchronize configuration']);
$this->drupalLogin($this->webUser);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
}
@ -54,7 +54,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
unset($core['module']['testing_config_import']);
$sync->write('core.extension', $core);
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
$this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
$this->assertText('Unable to uninstall the Testing config import profile since it is the install profile.');
@ -69,7 +69,7 @@ class ConfigImportInstallProfileTest extends WebTestBase {
$theme = $sync->read('system.theme');
$theme['default'] = 'classy';
$sync->write('system.theme', $theme);
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
$this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertText('The configuration was imported successfully.');
$this->rebuildContainer();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('syslog'), 'The syslog module has been uninstalled.');

View file

@ -19,7 +19,7 @@ class ConfigImportUITest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config', 'config_test', 'config_import_test', 'text', 'options');
public static $modules = ['config', 'config_test', 'config_import_test', 'text', 'options'];
/**
* A user with the 'synchronize configuration' permission.
@ -31,7 +31,7 @@ class ConfigImportUITest extends WebTestBase {
protected function setUp() {
parent::setUp();
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->webUser = $this->drupalCreateUser(['synchronize configuration']);
$this->drupalLogin($this->webUser);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
}
@ -39,7 +39,7 @@ class ConfigImportUITest extends WebTestBase {
/**
* Tests importing configuration.
*/
function testImport() {
public function testImport() {
$name = 'system.site';
$dynamic_name = 'config_test.dynamic.new';
/** @var \Drupal\Core\Config\StorageInterface $sync */
@ -55,11 +55,11 @@ class ConfigImportUITest extends WebTestBase {
$this->assertIdentical($sync->exists($name), TRUE, $name . ' found.');
// Create new config entity.
$original_dynamic_data = array(
$original_dynamic_data = [
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
'status' => TRUE,
'dependencies' => array(),
'dependencies' => [],
'id' => 'new',
'label' => 'New',
'weight' => 0,
@ -67,7 +67,7 @@ class ConfigImportUITest extends WebTestBase {
'size' => '',
'size_value' => '',
'protected_property' => '',
);
];
$sync->write($dynamic_name, $original_dynamic_data);
$this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.');
@ -102,11 +102,11 @@ class ConfigImportUITest extends WebTestBase {
// handled correctly. Options depends on Text so Text should be installed
// first. Since they were enabled during the test setup the core.extension
// file in sync will already contain them.
\Drupal::service('module_installer')->uninstall(array('text', 'options'));
\Drupal::service('module_installer')->uninstall(['text', 'options']);
// Set the state system to record installations and uninstallations.
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array());
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', array());
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', []);
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', []);
// Verify that both appear as ready to import.
$this->drupalGet('admin/config/development/configuration');
@ -118,7 +118,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertFieldById('edit-submit', t('Import all'));
// Import and verify that both do not appear anymore.
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoRaw('<td>' . $name);
$this->assertNoRaw('<td>' . $dynamic_name);
$this->assertNoRaw('<td>core.extension');
@ -150,9 +150,9 @@ class ConfigImportUITest extends WebTestBase {
$this->assertTrue($theme_info['bartik']->status, 'Bartik theme installed during import.');
// Ensure installations and uninstallation occur as expected.
$installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array());
$uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
$expected = array('action', 'ban', 'text', 'options');
$installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []);
$uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
$expected = ['action', 'ban', 'text', 'options'];
$this->assertIdentical($expected, $installed, 'Action, Ban, Text and Options modules installed in the correct order.');
$this->assertTrue(empty($uninstalled), 'No modules uninstalled during import');
@ -161,8 +161,8 @@ class ConfigImportUITest extends WebTestBase {
// configuration. This verifies that the module's default configuration is
// used during configuration import and, additionally, that after installing
// a module, that configuration is not synced twice.
$recursion_limit_values = \Drupal::state()->get('ConfigImportUITest.action.settings.recursion_limit', array());
$this->assertIdentical($recursion_limit_values, array(50));
$recursion_limit_values = \Drupal::state()->get('ConfigImportUITest.action.settings.recursion_limit', []);
$this->assertIdentical($recursion_limit_values, [50]);
$core_extension = $this->config('core.extension')->get();
unset($core_extension['module']['action']);
@ -180,8 +180,8 @@ class ConfigImportUITest extends WebTestBase {
$sync->write('system.theme', $system_theme);
// Set the state system to record installations and uninstallations.
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array());
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', array());
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', []);
\Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', []);
// Verify that both appear as ready to import.
$this->drupalGet('admin/config/development/configuration');
@ -190,7 +190,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertRaw('<td>action.settings');
// Import and verify that both do not appear anymore.
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoRaw('<td>core.extension');
$this->assertNoRaw('<td>system.theme');
$this->assertNoRaw('<td>action.settings');
@ -203,9 +203,9 @@ class ConfigImportUITest extends WebTestBase {
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('text'), 'Text module uninstalled during import.');
// Ensure installations and uninstallation occur as expected.
$installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array());
$uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
$expected = array('options', 'text', 'ban', 'action');
$installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []);
$uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
$expected = ['options', 'text', 'ban', 'action'];
$this->assertIdentical($expected, $uninstalled, 'Options, Text, Ban and Action modules uninstalled in the correct order.');
$this->assertTrue(empty($installed), 'No modules installed during import');
@ -221,7 +221,7 @@ class ConfigImportUITest extends WebTestBase {
/**
* Tests concurrent importing of configuration.
*/
function testImportLock() {
public function testImportLock() {
// Create updated configuration object.
$new_site_name = 'Config import test ' . $this->randomString();
$this->prepareSiteNameUpdate($new_site_name);
@ -235,7 +235,7 @@ class ConfigImportUITest extends WebTestBase {
$this->container->get('lock.persistent')->acquire($config_importer::LOCK_NAME);
// Attempt to import configuration and verify that an error message appears.
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->drupalPostForm(NULL, [], t('Import all'));
$this->assertText(t('Another request may be synchronizing configuration already.'));
// Release the lock, just to keep testing sane.
@ -248,7 +248,7 @@ class ConfigImportUITest extends WebTestBase {
/**
* Tests verification of site UUID before importing configuration.
*/
function testImportSiteUuidValidation() {
public function testImportSiteUuidValidation() {
$sync = \Drupal::service('config.storage.sync');
// Create updated configuration object.
$config_data = $this->config('system.site')->get();
@ -265,7 +265,7 @@ class ConfigImportUITest extends WebTestBase {
/**
* Tests the screen that shows differences between active and sync.
*/
function testImportDiff() {
public function testImportDiff() {
$sync = $this->container->get('config.storage.sync');
$config_name = 'config_test.system';
$change_key = 'foo';
@ -273,11 +273,11 @@ class ConfigImportUITest extends WebTestBase {
$add_key = 'biff';
$add_data = '<em>bangpow</em>';
$change_data = '<p><em>foobar</em></p>';
$original_data = array(
$original_data = [
'foo' => '<p>foobar</p>',
'baz' => '<strong>no change</strong>',
'404' => '<em>herp</em>',
);
];
// Update active storage to have html in config data.
$this->config($config_name)->setData($original_data)->save();
@ -290,7 +290,8 @@ class ConfigImportUITest extends WebTestBase {
// Load the diff UI and verify that the diff reflects the change.
$this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
$this->assertTitle(format_string('View changes of @config_name | Drupal', array('@config_name' => $config_name)));
$this->assertNoRaw('&amp;nbsp;');
$this->assertTitle(format_string('View changes of @config_name | Drupal', ['@config_name' => $config_name]));
// The following assertions do not use $this::assertEscaped() because
// \Drupal\Component\Diff\DiffFormatter adds markup that signifies what has
@ -307,7 +308,7 @@ class ConfigImportUITest extends WebTestBase {
$this->assertText(Html::escape("404: '<em>herp</em>'"));
// Verify diff colors are displayed.
$result = $this->xpath('//table[contains(@class, :class)]', array(':class' => 'diff'));
$result = $this->xpath('//table[contains(@class, :class)]', [':class' => 'diff']);
$this->assertEqual(count($result), 1, "Diff UI is displaying colors.");
// Reset data back to original, and remove a key
@ -351,7 +352,7 @@ class ConfigImportUITest extends WebTestBase {
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->drupalPostForm(NULL, [], t('Import all'));
// Verify that the validation messages appear.
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
@ -373,11 +374,11 @@ class ConfigImportUITest extends WebTestBase {
$this->assertText('core.extension');
// Import and verify that both do not appear anymore.
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->drupalPostForm(NULL, [], t('Import all'));
$this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.');
}
function prepareSiteNameUpdate($new_site_name) {
public function prepareSiteNameUpdate($new_site_name) {
$sync = $this->container->get('config.storage.sync');
// Create updated configuration object.
$config_data = $this->config('system.site')->get();
@ -388,17 +389,17 @@ class ConfigImportUITest extends WebTestBase {
/**
* Tests an import that results in an error.
*/
function testImportErrorLog() {
public function testImportErrorLog() {
$name_primary = 'config_test.dynamic.primary';
$name_secondary = 'config_test.dynamic.secondary';
$sync = $this->container->get('config.storage.sync');
$uuid = $this->container->get('uuid');
$values_primary = array(
$values_primary = [
'uuid' => $uuid->generate(),
'langcode' => 'en',
'status' => TRUE,
'dependencies' => array(),
'dependencies' => [],
'id' => 'primary',
'label' => 'Primary',
'weight' => 0,
@ -406,16 +407,16 @@ class ConfigImportUITest extends WebTestBase {
'size' => NULL,
'size_value' => NULL,
'protected_property' => NULL,
);
];
$sync->write($name_primary, $values_primary);
$values_secondary = array(
$values_secondary = [
'uuid' => $uuid->generate(),
'langcode' => 'en',
'status' => TRUE,
// Add a dependency on primary, to ensure that is synced first.
'dependencies' => array(
'config' => array($name_primary),
),
'dependencies' => [
'config' => [$name_primary],
],
'id' => 'secondary',
'label' => 'Secondary Sync',
'weight' => 0,
@ -423,15 +424,15 @@ class ConfigImportUITest extends WebTestBase {
'size' => NULL,
'size_value' => NULL,
'protected_property' => NULL,
);
];
$sync->write($name_secondary, $values_secondary);
// Verify that there are configuration differences to import.
$this->drupalGet('admin/config/development/configuration');
$this->assertNoText(t('There are no configuration changes to import.'));
// Attempt to import configuration and verify that an error message appears.
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary)));
$this->drupalPostForm(NULL, [], t('Import all'));
$this->assertText(SafeMarkup::format('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.'));
@ -443,42 +444,42 @@ class ConfigImportUITest extends WebTestBase {
* @see \Drupal\Core\Entity\Event\BundleConfigImportValidate
*/
public function testEntityBundleDelete() {
\Drupal::service('module_installer')->install(array('node'));
\Drupal::service('module_installer')->install(['node']);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
$node_type = $this->drupalCreateContentType();
$node = $this->drupalCreateNode(array('type' => $node_type->id()));
$node = $this->drupalCreateNode(['type' => $node_type->id()]);
$this->drupalGet('admin/config/development/configuration');
// The node type, body field and entity displays will be scheduled for
// removal.
$this->assertText(format_string('node.type.@type', array('@type' => $node_type->id())));
$this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
$this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
$this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
$this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
$this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()]));
$this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()]));
$this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
$this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()]));
$this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()]));
// Attempt to import configuration and verify that an error message appears
// and the node type, body field and entity displays are still scheduled for
// removal.
$this->drupalPostForm(NULL, array(), t('Import all'));
$validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()));
$this->drupalPostForm(NULL, [], t('Import all'));
$validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]);
$this->assertRaw($validation_message);
$this->assertText(format_string('node.type.@type', array('@type' => $node_type->id())));
$this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
$this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
$this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
$this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
$this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()]));
$this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()]));
$this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
$this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()]));
$this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()]));
// Delete the node and try to import again.
$node->delete();
$this->drupalPostForm(NULL, array(), t('Import all'));
$this->drupalPostForm(NULL, [], t('Import all'));
$this->assertNoRaw($validation_message);
$this->assertText(t('There are no configuration changes to import.'));
$this->assertNoText(format_string('node.type.@type', array('@type' => $node_type->id())));
$this->assertNoText(format_string('field.field.node.@type.body', array('@type' => $node_type->id())));
$this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id())));
$this->assertNoText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id())));
$this->assertNoText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id())));
$this->assertNoText(format_string('node.type.@type', ['@type' => $node_type->id()]));
$this->assertNoText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()]));
$this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
$this->assertNoText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()]));
$this->assertNoText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()]));
}
/**
@ -508,7 +509,7 @@ class ConfigImportUITest extends WebTestBase {
$core['theme']['does_not_exist'] = 0;
$sync->write('core.extension', $core);
$this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
$this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
$this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
$this->assertText('Unable to uninstall the Text module since the Node module is installed.');
$this->assertText('Unable to uninstall the Classy theme since the Bartik theme is installed.');

View file

@ -23,26 +23,26 @@ class ConfigImportUploadTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config');
public static $modules = ['config'];
protected function setUp() {
parent::setUp();
$this->webUser = $this->drupalCreateUser(array('import configuration'));
$this->webUser = $this->drupalCreateUser(['import configuration']);
$this->drupalLogin($this->webUser);
}
/**
* Tests importing configuration.
*/
function testImport() {
public function testImport() {
// Verify access to the config upload form.
$this->drupalGet('admin/config/development/configuration/full/import');
$this->assertResponse(200);
// Attempt to upload a non-tar file.
$text_file = current($this->drupalGetTestFiles('text'));
$edit = array('files[import_tarball]' => drupal_realpath($text_file->uri));
$edit = ['files[import_tarball]' => drupal_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'));

View file

@ -90,7 +90,7 @@ class ConfigInstallProfileUnmetDependenciesTest extends InstallerTestBase {
else {
$this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception thrown');
}
$this->assertErrorLogged('Configuration objects (system.action.user_block_user_action) provided by user have unmet dependencies in');
$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>');
}
}

View file

@ -26,7 +26,7 @@ class ConfigInstallWebTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer themes', 'administer site configuration'));
$this->adminUser = $this->drupalCreateUser(['administer modules', 'administer themes', 'administer site configuration']);
// Ensure the global variable being asserted by this test does not exist;
// a previous test executed in this request/process might have set it.
@ -36,12 +36,12 @@ class ConfigInstallWebTest extends WebTestBase {
/**
* Tests module re-installation.
*/
function testIntegrationModuleReinstallation() {
public function testIntegrationModuleReinstallation() {
$default_config = 'config_integration_test.settings';
$default_configuration_entity = 'config_test.dynamic.config_integration_test';
// Install the config_test module we're integrating with.
\Drupal::service('module_installer')->install(array('config_test'));
\Drupal::service('module_installer')->install(['config_test']);
// Verify the configuration does not exist prior to installation.
$config_static = $this->config($default_config);
@ -50,7 +50,7 @@ class ConfigInstallWebTest extends WebTestBase {
$this->assertIdentical($config_entity->isNew(), TRUE);
// Install the integration module.
\Drupal::service('module_installer')->install(array('config_integration_test'));
\Drupal::service('module_installer')->install(['config_integration_test']);
// Verify that default module config exists.
\Drupal::configFactory()->reset($default_config);
@ -73,7 +73,7 @@ class ConfigInstallWebTest extends WebTestBase {
$this->container->get('config.factory')->reset();
// Disable and uninstall the integration module.
$this->container->get('module_installer')->uninstall(array('config_integration_test'));
$this->container->get('module_installer')->uninstall(['config_integration_test']);
// Verify the integration module's config was uninstalled.
$config_static = $this->config($default_config);
@ -86,7 +86,7 @@ class ConfigInstallWebTest extends WebTestBase {
// Reinstall the integration module.
try {
\Drupal::service('module_installer')->install(array('config_integration_test'));
\Drupal::service('module_installer')->install(['config_integration_test']);
$this->fail('Expected PreExistingConfigException not thrown.');
}
catch (PreExistingConfigException $e) {
@ -97,7 +97,7 @@ class ConfigInstallWebTest extends WebTestBase {
// Delete the configuration entity so that the install will work.
$config_entity->delete();
\Drupal::service('module_installer')->install(array('config_integration_test'));
\Drupal::service('module_installer')->install(['config_integration_test']);
// Verify the integration module's config was re-installed.
\Drupal::configFactory()->reset($default_config);
@ -122,19 +122,19 @@ class ConfigInstallWebTest extends WebTestBase {
// will install the config_test module first because it is a dependency of
// config_install_fail_test.
// @see \Drupal\system\Form\ModulesListForm::submitForm()
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE, 'modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
// Uninstall the config_test module to test the confirm form.
$this->drupalPostForm('admin/modules/uninstall', array('uninstall[config_test]' => TRUE), t('Uninstall'));
$this->drupalPostForm(NULL, array(), t('Uninstall'));
$this->drupalPostForm('admin/modules/uninstall', ['uninstall[config_test]' => TRUE], t('Uninstall'));
$this->drupalPostForm(NULL, [], t('Uninstall'));
// Try to install config_install_fail_test without selecting config_test.
// The user is shown a confirm form because the config_test module is a
// dependency.
// @see \Drupal\system\Form\ModulesListConfirmForm::submitForm()
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm(NULL, array(), t('Continue'));
$this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install'));
$this->drupalPostForm(NULL, [], t('Continue'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
// Test that collection configuration clashes during a module install are
@ -147,7 +147,7 @@ class ConfigInstallWebTest extends WebTestBase {
->set('label', 'Je suis Charlie')
->save();
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install Configuration install fail test, <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 UI that has existing configuration.
@ -178,12 +178,16 @@ class ConfigInstallWebTest extends WebTestBase {
$this->drupalLogin($this->adminUser);
// We need to install separately since config_install_dependency_test does
// not depend on config_test and order is important.
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install Config install dependency test, <em class="placeholder">config_other_module_config_test.weird_simple_config, config_test.dynamic.other_module_test_with_dependency</em> have unmet dependencies.');
$this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE], t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
$this->drupalPostForm('admin/modules', array('modules[Testing][config_other_module_config_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_test_language][enable]' => TRUE], t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
$this->drupalPostForm('admin/modules', ['modules[config_other_module_config_test][enable]' => TRUE], t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
$this->rebuildContainer();
$this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.');
}
@ -193,12 +197,12 @@ class ConfigInstallWebTest extends WebTestBase {
*/
public function testConfigModuleRequirements() {
$this->drupalLogin($this->adminUser);
$this->drupalPostForm('admin/modules', array('modules[Core][config][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', ['modules[config][enable]' => TRUE], t('Install'));
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
file_unmanaged_delete_recursive($directory);
$this->drupalGet('/admin/reports/status');
$this->assertRaw(t('The directory %directory does not exist.', array('%directory' => $directory)));
$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);

View file

@ -39,7 +39,7 @@ class ConfigSingleImportExportTest extends WebTestBase {
$storage = \Drupal::entityManager()->getStorage('config_test');
$uuid = \Drupal::service('uuid');
$this->drupalLogin($this->drupalCreateUser(array('import configuration')));
$this->drupalLogin($this->drupalCreateUser(['import configuration']));
// Attempt an import with invalid YAML.
$edit = [
@ -57,20 +57,20 @@ weight: 0
style: ''
status: '1'
EOD;
$edit = array(
$edit = [
'config_type' => 'config_test',
'import' => $import,
);
];
// Attempt an import with a missing ID.
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => 'id', '@entity_type' => 'Test configuration')));
$this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => 'id', '@entity_type' => 'Test configuration']));
// Perform an import with no specified UUID and a unique ID.
$this->assertNull($storage->load('first'));
$edit['import'] = "id: first\n" . $edit['import'];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'first', '@type' => 'test configuration')));
$this->drupalPostForm(NULL, array(), t('Confirm'));
$this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration']));
$this->drupalPostForm(NULL, [], t('Confirm'));
$entity = $storage->load('first');
$this->assertIdentical($entity->label(), 'First');
$this->assertIdentical($entity->id(), 'first');
@ -89,8 +89,8 @@ EOD;
// Attempt an import with a custom ID.
$edit['custom_entity_id'] = 'custom_id';
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'custom_id', '@type' => 'test configuration')));
$this->drupalPostForm(NULL, array(), t('Confirm'));
$this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration']));
$this->drupalPostForm(NULL, [], t('Confirm'));
$this->assertRaw(t('The configuration was imported successfully.'));
// Perform an import with a unique ID and UUID.
@ -101,15 +101,15 @@ weight: 0
style: ''
status: '0'
EOD;
$edit = array(
$edit = [
'config_type' => 'config_test',
'import' => $import,
);
];
$second_uuid = $uuid->generate();
$edit['import'] .= "\nuuid: " . $second_uuid;
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'second', '@type' => 'test configuration')));
$this->drupalPostForm(NULL, array(), t('Confirm'));
$this->assertRaw(t('Are you sure you want to create a new %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->assertIdentical($entity->label(), 'Second');
@ -126,13 +126,13 @@ weight: 0
style: ''
status: '0'
EOD;
$edit = array(
$edit = [
'config_type' => 'config_test',
'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?', array('%name' => 'second', '@type' => 'test configuration')));
$this->drupalPostForm(NULL, array(), t('Confirm'));
$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->assertIdentical($entity->label(), 'Second updated');
@ -149,10 +149,10 @@ dependencies:
module:
- does_not_exist
EOD;
$edit = array(
$edit = [
'config_type' => 'config_test',
'import' => $import,
);
];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist']));
}
@ -161,20 +161,20 @@ EOD;
* Tests importing a simple configuration file.
*/
public function testImportSimpleConfiguration() {
$this->drupalLogin($this->drupalCreateUser(array('import configuration')));
$this->drupalLogin($this->drupalCreateUser(['import configuration']));
$config = $this->config('system.site')->set('name', 'Test simple import');
// Place branding block with site name into header region.
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
$edit = array(
$edit = [
'config_type' => 'system.simple',
'config_name' => $config->getName(),
'import' => Yaml::encode($config->get()),
);
];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => $config->getName(), '@type' => 'simple configuration')));
$this->drupalPostForm(NULL, array(), t('Confirm'));
$this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration']));
$this->drupalPostForm(NULL, [], t('Confirm'));
$this->drupalGet('');
$this->assertText('Test simple import');
@ -183,11 +183,11 @@ EOD;
$config_data = $this->config('core.extension')->get();
// Simulate uninstalling the Config module.
unset($config_data['module']['config']);
$edit = array(
$edit = [
'config_type' => 'system.simple',
'config_name' => 'core.extension',
'import' => Yaml::encode($config_data),
);
];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertText(t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
@ -197,14 +197,14 @@ EOD;
* Tests exporting a single configuration file.
*/
public function testExport() {
$this->drupalLogin($this->drupalCreateUser(array('export configuration')));
$this->drupalLogin($this->drupalCreateUser(['export configuration']));
$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]);
$expected_options = array('system.site', 'user.settings');
$expected_options = ['system.site', 'user.settings'];
foreach ($options as &$option) {
$option = (string) $option;
}

View file

@ -12,7 +12,7 @@ use Drupal\simpletest\WebTestBase;
*/
class LanguageNegotiationFormOverrideTest extends WebTestBase {
public static $modules = array('language', 'locale', 'locale_test');
public static $modules = ['language', 'locale', 'locale_test'];
/**
* Tests that overrides do not affect language-negotiation form values.
@ -23,16 +23,16 @@ class LanguageNegotiationFormOverrideTest extends WebTestBase {
$overridden_value_es = 'loquesea';
// Set up an override.
$settings['config']['language.negotiation']['url']['prefixes'] = (object) array(
'value' => array('en' => $overridden_value_en, 'es' => $overridden_value_es),
$settings['config']['language.negotiation']['url']['prefixes'] = (object) [
'value' => ['en' => $overridden_value_en, 'es' => $overridden_value_es],
'required' => TRUE,
);
];
$this->writeSettings($settings);
// Add predefined language.
$edit = array(
$edit = [
'predefined_langcode' => 'es',
);
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Overridden string for language-negotiation should not exist in the form.

View file

@ -2,58 +2,13 @@
namespace Drupal\config\Tests;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Config\Schema\SchemaCheckTrait;
use Drupal\Component\Utility\SafeMarkup;
/**
* Provides a class for checking configuration schema.
*
* @deprecated as of 8.3.x, will be removed in before Drupal 9.0.0.
*/
trait SchemaCheckTestTrait {
use SchemaCheckTrait;
/**
* Asserts the TypedConfigManager has a valid schema for the configuration.
*
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
* The TypedConfigManager.
* @param string $config_name
* The configuration name.
* @param array $config_data
* The configuration data.
*/
public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data) {
$errors = $this->checkConfigSchema($typed_config, $config_name, $config_data);
if ($errors === FALSE) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
$this->fail(SafeMarkup::format('No schema for @config_name', array('@config_name' => $config_name)));
return;
}
elseif ($errors === TRUE) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
$this->pass(SafeMarkup::format('Schema found for @config_name and values comply with schema.', array('@config_name' => $config_name)));
}
else {
foreach ($errors as $key => $error) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
$this->fail(SafeMarkup::format('Schema key @key failed with: @error', array('@key' => $key, '@error' => $error)));
}
}
}
/**
* Asserts configuration, specified by name, has a valid schema.
*
* @param string $config_name
* The configuration name.
*/
public function assertConfigSchemaByName($config_name) {
$config = $this->config($config_name);
$this->assertConfigSchema(\Drupal::service('config.typed'), $config->getName(), $config->get());
}
use \Drupal\Tests\SchemaCheckTestTrait;
}

View file

@ -33,7 +33,7 @@ class EventSubscriber implements EventSubscriberInterface {
* The configuration collection info event.
*/
public function addCollections(ConfigCollectionInfo $collection_info) {
$collections = $this->state->get('config_collection_install_test.collection_names', array());
$collections = $this->state->get('config_collection_install_test.collection_names', []);
foreach ($collections as $collection) {
$collection_info->addCollection($collection);
}
@ -42,8 +42,8 @@ class EventSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[ConfigEvents::COLLECTION_INFO][] = array('addCollections');
public static function getSubscribedEvents() {
$events[ConfigEvents::COLLECTION_INFO][] = ['addCollections'];
return $events;
}

View file

@ -15,11 +15,11 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface {
* {@inheritdoc}
*/
public function loadOverrides($names) {
return array(
'config_test.dynamic.test_1' => array(
return [
'config_test.dynamic.test_1' => [
'label' => 'Overridden label',
)
);
]
];
}
/**

View file

@ -37,21 +37,21 @@ class EventSubscriber implements EventSubscriberInterface {
*/
public function configEventRecorder(ConfigCrudEvent $event, $name) {
$config = $event->getConfig();
$this->state->set('config_events_test.event', array(
$this->state->set('config_events_test.event', [
'event_name' => $name,
'current_config_data' => $config->get(),
'original_config_data' => $config->getOriginal(),
'raw_config_data' => $config->getRawData()
));
]);
}
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = array('configEventRecorder');
$events[ConfigEvents::DELETE][] = array('configEventRecorder');
$events[ConfigEvents::RENAME][] = array('configEventRecorder');
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = ['configEventRecorder'];
$events[ConfigEvents::DELETE][] = ['configEventRecorder'];
$events[ConfigEvents::RENAME][] = ['configEventRecorder'];
return $events;
}

View file

@ -88,14 +88,14 @@ class EventSubscriber implements EventSubscriberInterface {
public function onConfigSave(ConfigCrudEvent $event) {
$config = $event->getConfig();
if ($config->getName() == 'action.settings') {
$values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', array());
$values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', []);
$values[] = $config->get('recursion_limit');
$this->state->set('ConfigImportUITest.action.settings.recursion_limit', $values);
}
if ($config->getName() == 'core.extension') {
$installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', array());
$uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', array());
$installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', []);
$uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', []);
$original = $config->getOriginal('module');
$data = $config->get('module');
$install = array_diff_key($data, $original);
@ -131,11 +131,11 @@ class EventSubscriber implements EventSubscriberInterface {
* @return array
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = array('onConfigSave', 40);
$events[ConfigEvents::DELETE][] = array('onConfigDelete', 40);
$events[ConfigEvents::IMPORT_VALIDATE] = array('onConfigImporterValidate');
$events[ConfigEvents::IMPORT_MISSING_CONTENT] = array(array('onConfigImporterMissingContentOne'), array('onConfigImporterMissingContentTwo', -100));
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = ['onConfigSave', 40];
$events[ConfigEvents::DELETE][] = ['onConfigDelete', 40];
$events[ConfigEvents::IMPORT_VALIDATE] = ['onConfigImporterValidate'];
$events[ConfigEvents::IMPORT_MISSING_CONTENT] = [['onConfigImporterMissingContentOne'], ['onConfigImporterMissingContentTwo', -100]];
return $events;
}

View file

@ -9,3 +9,5 @@ dependencies:
enforced:
module:
- config_other_module_config_test
config:
- config_test.dynamic.dotted.english

View file

@ -1,4 +1,4 @@
threshold:
requirements_warning: 172800
requirements_error: 1209600
logging: 1

View file

@ -14,13 +14,13 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface {
* {@inheritdoc}
*/
public function loadOverrides($names) {
$overrides = array();
$overrides = [];
if (!empty($GLOBALS['config_test_run_module_overrides'])) {
if (in_array('system.site', $names)) {
$overrides = $overrides + array('system.site' => array('name' => 'ZOMG overridden site name'));
$overrides = $overrides + ['system.site' => ['name' => 'ZOMG overridden site name']];
}
if (in_array('config_override_test.new', $names)) {
$overrides = $overrides + array('config_override_test.new' => array('module' => 'override'));
$overrides = $overrides + ['config_override_test.new' => ['module' => 'override']];
}
}
return $overrides;

View file

@ -15,17 +15,17 @@ class ConfigOverriderLowPriority implements ConfigFactoryOverrideInterface {
* {@inheritdoc}
*/
public function loadOverrides($names) {
$overrides = array();
$overrides = [];
if (!empty($GLOBALS['config_test_run_module_overrides'])) {
if (in_array('system.site', $names)) {
$overrides = array('system.site' =>
array(
$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!',
)
);
]
];
}
}
return $overrides;

View file

@ -270,3 +270,30 @@ test.double_brackets.turtle.horse:
test.double_brackets.*:
type: mapping
wrapping.config_schema_test.other_double_brackets:
type: config_object
mapping:
tests:
type: sequence
sequence:
- type: wrapping.test.other_double_brackets.[id]
wrapping.test.other_double_brackets.*:
type: test.double_brackets.[id]
mapping:
id:
type: string
foo:
type: string
bar:
type: string
test.double_brackets.cat:*.*:
type: test.double_brackets.breed
test.double_brackets.breed:
type: test.double_brackets
mapping:
breed:
type: string

View file

@ -21,7 +21,7 @@ class ConfigTestController extends ControllerBase {
* The title for the ConfigTest edit form.
*/
public function editTitle(ConfigTest $config_test) {
return $this->t('Edit %label', array('%label' => $config_test->label()));
return $this->t('Edit %label', ['%label' => $config_test->label()]);
}
/**
@ -33,9 +33,9 @@ class ConfigTestController extends ControllerBase {
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect response to the config_test listing page.
*/
function enable(ConfigTest $config_test) {
public function enable(ConfigTest $config_test) {
$config_test->enable()->save();
return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE)));
return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
}
/**
@ -47,9 +47,9 @@ class ConfigTestController extends ControllerBase {
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect response to the config_test listing page.
*/
function disable(ConfigTest $config_test) {
public function disable(ConfigTest $config_test) {
$config_test->disable()->save();
return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE)));
return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE]));
}
}

View file

@ -3,42 +3,14 @@
namespace Drupal\config_test;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Form controller for the test config edit forms.
*/
class ConfigTestForm extends EntityForm {
/**
* The entity query.
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $entityQuery;
/**
* Constructs a new ConfigTestForm.
*
* @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
* The entity query.
*/
public function __construct(QueryFactory $entity_query) {
$this->entityQuery = $entity_query;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.query')
);
}
/**
* {@inheritdoc}
*/
@ -46,33 +18,33 @@ class ConfigTestForm extends EntityForm {
$form = parent::form($form, $form_state);
$entity = $this->entity;
$form['label'] = array(
$form['label'] = [
'#type' => 'textfield',
'#title' => 'Label',
'#default_value' => $entity->label(),
'#required' => TRUE,
);
$form['id'] = array(
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity->id(),
'#required' => TRUE,
'#machine_name' => array(
'#machine_name' => [
'exists' => [$this, 'exists'],
'replace_pattern' => '[^a-z0-9_.]+',
),
);
$form['weight'] = array(
],
];
$form['weight'] = [
'#type' => 'weight',
'#title' => 'Weight',
'#default_value' => $entity->get('weight'),
);
$form['style'] = array(
];
$form['style'] = [
'#type' => 'select',
'#title' => 'Image style',
'#options' => array(),
'#options' => [],
'#default_value' => $entity->get('style'),
'#access' => FALSE,
);
];
if ($this->moduleHandler->moduleExists('image')) {
$form['style']['#access'] = TRUE;
$form['style']['#options'] = image_style_options();
@ -83,61 +55,61 @@ class ConfigTestForm extends EntityForm {
// state.
$size = $entity->get('size');
$form['size_wrapper'] = array(
$form['size_wrapper'] = [
'#type' => 'container',
'#attributes' => array(
'#attributes' => [
'id' => 'size-wrapper',
),
);
$form['size_wrapper']['size'] = array(
],
];
$form['size_wrapper']['size'] = [
'#type' => 'select',
'#title' => 'Size',
'#options' => array(
'#options' => [
'custom' => 'Custom',
),
],
'#empty_option' => '- None -',
'#default_value' => $size,
'#ajax' => array(
'#ajax' => [
'callback' => '::updateSize',
'wrapper' => 'size-wrapper',
),
);
$form['size_wrapper']['size_submit'] = array(
],
];
$form['size_wrapper']['size_submit'] = [
'#type' => 'submit',
'#value' => t('Change size'),
'#attributes' => array(
'class' => array('js-hide'),
),
'#submit' => array(array(get_class($this), 'changeSize')),
);
$form['size_wrapper']['size_value'] = array(
'#attributes' => [
'class' => ['js-hide'],
],
'#submit' => [[get_class($this), 'changeSize']],
];
$form['size_wrapper']['size_value'] = [
'#type' => 'select',
'#title' => 'Custom size value',
'#options' => array(
'#options' => [
'small' => 'Small',
'medium' => 'Medium',
'large' => 'Large',
),
],
'#default_value' => $entity->get('size_value'),
'#access' => !empty($size),
);
];
$form['langcode'] = array(
$form['langcode'] = [
'#type' => 'language_select',
'#title' => t('Language'),
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => $entity->language()->getId(),
);
];
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
$form['actions'] = ['#type' => 'actions'];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
);
$form['actions']['delete'] = array(
];
$form['actions']['delete'] = [
'#type' => 'submit',
'#value' => 'Delete',
);
];
return $form;
}
@ -164,10 +136,10 @@ class ConfigTestForm extends EntityForm {
$status = $entity->save();
if ($status === SAVED_UPDATED) {
drupal_set_message(format_string('%label configuration has been updated.', array('%label' => $entity->label())));
drupal_set_message(format_string('%label configuration has been updated.', ['%label' => $entity->label()]));
}
else {
drupal_set_message(format_string('%label configuration has been created.', array('%label' => $entity->label())));
drupal_set_message(format_string('%label configuration has been created.', ['%label' => $entity->label()]));
}
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
@ -189,7 +161,8 @@ class ConfigTestForm extends EntityForm {
public function exists($entity_id, array $element, FormStateInterface $form_state) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
$entity = $form_state->getFormObject()->getEntity();
return (bool) $this->entityQuery->get($entity->getEntityTypeId())
return (bool) $this->entityTypeManager->getStorage($entity->getEntityTypeId())
->getQuery()
->condition($entity->getEntityType()->getKey('id'), $entity_id)
->execute();
}

View file

@ -38,6 +38,6 @@ class ConfigQueryTest extends ConfigTest {
*
* @var array
*/
public $array = array();
public $array = [];
}

View file

@ -88,10 +88,10 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
// Used to test secondary writes during config sync.
if ($this->id() == 'primary') {
$secondary = $storage->create(array(
$secondary = $storage->create([
'id' => 'secondary',
'label' => 'Secondary Default',
));
]);
$secondary->save();
}
if ($this->id() == 'deleter') {
@ -126,7 +126,7 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
if (!isset($this->dependencies['enforced']['config'])) {
return $changed;
}
$fix_deps = \Drupal::state()->get('config_test.fix_dependencies', array());
$fix_deps = \Drupal::state()->get('config_test.fix_dependencies', []);
foreach ($dependencies['config'] as $entity) {
if (in_array($entity->getConfigDependencyName(), $fix_deps)) {
$key = array_search($entity->getConfigDependencyName(), $this->dependencies['enforced']['config']);

View file

@ -8,7 +8,7 @@ use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Controller for testing \Drupal\Core\Config\Testing\ConfigSchemaChecker.
* Controller for testing \Drupal\Core\Config\Development\ConfigSchemaChecker.
*/
class SchemaListenerController extends ControllerBase {

View file

@ -20,7 +20,7 @@ class TestInstallStorage extends InstallStorage {
if (!isset($this->folders)) {
$this->folders = $this->getCoreNames();
$listing = new ExtensionDiscovery(\Drupal::root());
$listing->setProfileDirectories(array());
$listing->setProfileDirectories([]);
$this->folders += $this->getComponentNames($listing->scan('profile'));
$this->folders += $this->getComponentNames($listing->scan('module'));
$this->folders += $this->getComponentNames($listing->scan('theme'));

View file

@ -1,16 +1,16 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests configuration entities.
*
* @group config
*/
class ConfigDependencyWebTest extends WebTestBase {
class ConfigDependencyWebTest extends BrowserTestBase {
/**
* The maximum length for the entity storage used in this test.
@ -22,24 +22,24 @@ class ConfigDependencyWebTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('config_test');
public static $modules = ['config_test'];
/**
* Tests ConfigDependencyDeleteFormTrait.
*
* @see \Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait
*/
function testConfigDependencyDeleteFormTrait() {
public function testConfigDependencyDeleteFormTrait() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = $this->container->get('entity.manager')->getStorage('config_test');
// Entity1 will be deleted by the test.
$entity1 = $storage->create(
array(
[
'id' => 'entity1',
'label' => 'Entity One',
)
]
);
$entity1->save();
@ -47,14 +47,14 @@ class ConfigDependencyWebTest extends WebTestBase {
// \Drupal\config_test\Entity::onDependencyRemoval() will remove the
// dependency before config entities are deleted.
$entity2 = $storage->create(
array(
[
'id' => 'entity2',
'dependencies' => array(
'enforced' => array(
'config' => array($entity1->getConfigDependencyName()),
),
),
)
'dependencies' => [
'enforced' => [
'config' => [$entity1->getConfigDependencyName()],
],
],
]
);
$entity2->save();
@ -65,47 +65,47 @@ class ConfigDependencyWebTest extends WebTestBase {
$this->assertNoText(t('Configuration updates'), 'No configuration updates found.');
$this->assertText(t('Configuration deletions'), 'Configuration deletions found.');
$this->assertText($entity2->id(), 'Entity2 id found');
$this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete');
$this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete');
$storage->resetCache();
$this->assertFalse($storage->loadMultiple([$entity1->id(), $entity2->id()]), 'Test entities deleted');
// Set a more complicated test where dependencies will be fixed.
// Entity1 will be deleted by the test.
$entity1 = $storage->create(
array(
[
'id' => 'entity1',
)
]
);
$entity1->save();
\Drupal::state()->set('config_test.fix_dependencies', array($entity1->getConfigDependencyName()));
\Drupal::state()->set('config_test.fix_dependencies', [$entity1->getConfigDependencyName()]);
// Entity2 has a dependency on Entity1 but it can be fixed because
// \Drupal\config_test\Entity::onDependencyRemoval() will remove the
// dependency before config entities are deleted.
$entity2 = $storage->create(
array(
[
'id' => 'entity2',
'label' => 'Entity Two',
'dependencies' => array(
'enforced' => array(
'config' => array($entity1->getConfigDependencyName()),
),
),
)
'dependencies' => [
'enforced' => [
'config' => [$entity1->getConfigDependencyName()],
],
],
]
);
$entity2->save();
// Entity3 will be unchanged because it is dependent on Entity2 which can
// be fixed.
$entity3 = $storage->create(
array(
[
'id' => 'entity3',
'dependencies' => array(
'enforced' => array(
'config' => array($entity2->getConfigDependencyName()),
),
),
)
'dependencies' => [
'enforced' => [
'config' => [$entity2->getConfigDependencyName()],
],
],
]
);
$entity3->save();
@ -115,12 +115,12 @@ class ConfigDependencyWebTest extends WebTestBase {
$this->assertNoText($entity2->id(), 'Entity2 id not found');
$this->assertText($entity2->label(), 'Entity2 label not found');
$this->assertNoText($entity3->id(), 'Entity3 id not found');
$this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete');
$this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete');
$storage->resetCache();
$this->assertFalse($storage->load('entity1'), 'Test entity 1 deleted');
$entity2 = $storage->load('entity2');
$this->assertTrue($entity2, 'Entity 2 not deleted');
$this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.');
$this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], [], 'Entity 2 dependencies updated to remove dependency on Entity1.');
$entity3 = $storage->load('entity3');
$this->assertTrue($entity3, 'Entity 3 not deleted');
$this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.');

View file

@ -15,13 +15,13 @@ class ConfigDraggableListBuilderTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('config_test');
public static $modules = ['config_test'];
/**
* Test draggable lists.
*/
public function testDraggableList() {
$this->drupalLogin($this->drupalCreateUser(array('administer permissions')));
$this->drupalLogin($this->drupalCreateUser(['administer permissions']));
// Create more than 50 roles.
for ($i = 0; $i < 51; $i++) {

View file

@ -1,8 +1,8 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
/**
@ -10,14 +10,14 @@ use Drupal\language\Entity\ConfigurableLanguage;
*
* @group config
*/
class ConfigEntityListMultilingualTest extends WebTestBase {
class ConfigEntityListMultilingualTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('config_test', 'language', 'block');
public static $modules = ['config_test', 'language', 'block'];
/**
* {@inheritdoc}
@ -34,9 +34,9 @@ class ConfigEntityListMultilingualTest extends WebTestBase {
/**
* Tests the listing UI with different language scenarios.
*/
function testListUI() {
public function testListUI() {
// Log in as an administrative user to access the full menu trail.
$this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration')));
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
// Get the list page.
$this->drupalGet('admin/structure/config_test');
@ -44,11 +44,11 @@ class ConfigEntityListMultilingualTest extends WebTestBase {
// Add a new entity using the action link.
$this->clickLink('Add test configuration');
$edit = array(
$edit = [
'label' => 'Antilop',
'id' => 'antilop',
'langcode' => 'hu',
);
];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Ensure that operations for editing the Hungarian entity appear in English.
$this->assertLinkByHref('admin/structure/config_test/manage/antilop');

View file

@ -1,34 +1,34 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests configuration entity status UI functionality.
*
* @group config
*/
class ConfigEntityStatusUITest extends WebTestBase {
class ConfigEntityStatusUITest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('config_test');
public static $modules = ['config_test'];
/**
* Tests status operations.
*/
function testCRUD() {
public function testCRUD() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$id = strtolower($this->randomMachineName());
$edit = array(
$edit = [
'id' => $id,
'label' => $this->randomMachineName(),
);
];
$this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
$entity = entity_load('config_test', $id);

View file

@ -1,10 +1,10 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Config\InstallStorage;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Config\FileStorage;
use Drupal\system\Entity\Action;
use Drupal\tour\Entity\Tour;
@ -15,7 +15,7 @@ use Drupal\tour\Entity\Tour;
*
* @group config
*/
class ConfigInstallProfileOverrideTest extends WebTestBase {
class ConfigInstallProfileOverrideTest extends BrowserTestBase {
/**
* The profile to install as a basis for testing.
@ -28,22 +28,24 @@ class ConfigInstallProfileOverrideTest extends WebTestBase {
/**
* Tests install profile config changes.
*/
function testInstallProfileConfigOverwrite() {
public function testInstallProfileConfigOverwrite() {
$config_name = 'system.cron';
// The expected configuration from the system module.
$expected_original_data = array(
'threshold' => array(
$expected_original_data = [
'threshold' => [
'requirements_warning' => 172800,
'requirements_error' => 1209600,
),
);
],
'logging' => 1,
];
// The expected active configuration altered by the install profile.
$expected_profile_data = array(
'threshold' => array(
$expected_profile_data = [
'threshold' => [
'requirements_warning' => 259200,
'requirements_error' => 1209600,
),
);
],
'logging' => 1,
];
$expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data));
// Verify that the original data matches. We have to read the module config

View file

@ -1,17 +1,17 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests language overrides applied through the website.
*
* @group config
*/
class ConfigLanguageOverrideWebTest extends WebTestBase {
class ConfigLanguageOverrideWebTest extends BrowserTestBase {
/**
* Modules to install.
@ -34,19 +34,19 @@ class ConfigLanguageOverrideWebTest extends WebTestBase {
/**
* Tests translating the site name.
*/
function testSiteNameTranslation() {
$adminUser = $this->drupalCreateUser(array('administer site configuration', 'administer languages'));
public function testSiteNameTranslation() {
$adminUser = $this->drupalCreateUser(['administer site configuration', 'administer languages']);
$this->drupalLogin($adminUser);
// Add a custom language.
$langcode = 'xx';
$name = $this->randomMachineName(16);
$edit = array(
$edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
);
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
\Drupal::languageManager()
->getLanguageConfigOverride($langcode, 'system.site')

View file

@ -1,15 +1,15 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests default configuration provided by a module that does not own it.
*
* @group config
*/
class ConfigOtherModuleTest extends WebTestBase {
class ConfigOtherModuleTest extends BrowserTestBase {
/**
* Tests enabling the provider of the default configuration first.
@ -61,6 +61,7 @@ class ConfigOtherModuleTest extends WebTestBase {
// installed once all the dependencies are met.
$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->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
@ -86,14 +87,14 @@ class ConfigOtherModuleTest extends WebTestBase {
public function testUninstall() {
$this->installModule('views');
$storage = $this->container->get('entity_type.manager')->getStorage('view');
$storage->resetCache(array('frontpage'));
$storage->resetCache(['frontpage']);
$this->assertTrue($storage->load('frontpage') === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.');
$this->installModule('node');
$storage->resetCache(array('frontpage'));
$storage->resetCache(['frontpage']);
$this->assertTrue($storage->load('frontpage') !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.');
$this->uninstallModule('node');
$storage = $this->container->get('entity_type.manager')->getStorage('view');
$storage->resetCache(array('frontpage'));
$storage->resetCache(['frontpage']);
$this->assertTrue($storage->load('frontpage') === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.');
}
@ -104,7 +105,7 @@ class ConfigOtherModuleTest extends WebTestBase {
* The module name.
*/
protected function installModule($module) {
$this->container->get('module_installer')->install(array($module));
$this->container->get('module_installer')->install([$module]);
$this->container = \Drupal::getContainer();
}
@ -115,7 +116,7 @@ class ConfigOtherModuleTest extends WebTestBase {
* The module name.
*/
protected function uninstallModule($module) {
$this->container->get('module_installer')->uninstall(array($module));
$this->container->get('module_installer')->uninstall([$module]);
$this->container = \Drupal::getContainer();
}

View file

@ -1,24 +1,24 @@
<?php
namespace Drupal\config\Tests;
namespace Drupal\Tests\config\Functional;
use Drupal\Core\Config\Schema\SchemaIncompleteException;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the functionality of ConfigSchemaChecker in WebTestBase tests.
*
* @group config
*/
class SchemaConfigListenerWebTest extends WebTestBase {
class SchemaConfigListenerWebTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('config_test');
public static $modules = ['config_test'];
/**
* Tests \Drupal\Core\Config\Testing\ConfigSchemaChecker.
* Tests \Drupal\Core\Config\Development\ConfigSchemaChecker.
*/
public function testConfigSchemaChecker() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));

View file

@ -12,7 +12,7 @@ use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
class ConfigLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
$this->directoryList = array('config' => 'core/modules/config');
$this->directoryList = ['config' => 'core/modules/config'];
parent::setUp();
}
@ -29,13 +29,13 @@ class ConfigLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getConfigAdminRoutes() {
return array(
array('config.sync', array(array('config.sync', 'config.import', 'config.export'))),
array('config.import_full', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))),
array('config.import_single', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))),
array('config.export_full', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))),
array('config.export_single', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))),
);
return [
['config.sync', [['config.sync', 'config.import', 'config.export']]],
['config.import_full', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]],
['config.import_single', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]],
['config.export_full', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]],
['config.export_single', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]],
];
}
}