diff options
Diffstat (limited to 'core/modules/system')
43 files changed, 537 insertions, 452 deletions
diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml index cfd2f82952c..854ef2a178e 100644 --- a/core/modules/system/config/schema/system.schema.yml +++ b/core/modules/system/config/schema/system.schema.yml @@ -157,15 +157,13 @@ system.diff: label: 'Number of leading lines in a diff' constraints: # @see \Drupal\Component\Diff\DiffFormatter - Range: - min: 0 + PositiveOrZero: ~ lines_trailing: type: integer label: 'Number of trailing lines in a diff' constraints: # @see \Drupal\Component\Diff\DiffFormatter - Range: - min: 0 + PositiveOrZero: ~ system.logging: type: config_object @@ -355,8 +353,7 @@ system.file: type: integer label: 'Maximum age for temporary files' constraints: - Range: - min: 0 + PositiveOrZero: ~ system.image: type: config_object @@ -426,8 +423,7 @@ system.advisories: # Minimum can be set to 0 as it just means the advisories will be retrieved on every call. # @see \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher::getSecurityAdvisories constraints: - Range: - min: 0 + PositiveOrZero: ~ block.settings.system_branding_block: type: block_settings diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 0bd9e737f59..4fdb93c8b45 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -228,7 +228,7 @@ class DbUpdateController extends ControllerBase { $this->keyValueExpirableFactory->get('update_available_release')->deleteAll(); $build['info_header'] = [ - '#markup' => '<p>' . $this->t('Use this utility to update your database whenever a module, theme, or the core software is updated.') . '</p><p>' . $this->t('For more detailed information, see the <a href="https://www.drupal.org/upgrade">upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.') . '</p>', + '#markup' => '<p>' . $this->t('Use this utility to update your database whenever a module, theme, or the core software is updated.') . '</p><p>' . $this->t('For more detailed information, see the <a href="https://www.drupal.org/docs/updating-drupal">Updating Drupal guide</a>. If you are unsure what these terms mean you should probably contact your hosting provider.') . '</p>', ]; $info[] = $this->t("<strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism."); diff --git a/core/modules/system/src/CronController.php b/core/modules/system/src/CronController.php index 6ba1e031a4d..59bc6e9289a 100644 --- a/core/modules/system/src/CronController.php +++ b/core/modules/system/src/CronController.php @@ -37,7 +37,7 @@ class CronController extends ControllerBase { public function run() { $this->cron->run(); - // HTTP 204 is "No content", meaning "I did what you asked and we're done." + // HTTP 204 is "No content", meaning "I did what you asked and we're done.". return new Response('', 204); } diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 13297f3578c..551e813c611 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -329,7 +329,7 @@ class ModulesListForm extends FormBase { // Disable the checkbox for required modules. if (!empty($module->info['required'])) { // Used when displaying modules that are required by the installation - // profile + // profile. $row['enable']['#disabled'] = TRUE; $row['#required_by'][] = $distribution . (!empty($module->info['explanation']) ? ' (' . $module->info['explanation'] . ')' : ''); } diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php index 97f76abe40e..9d51b67f2d3 100644 --- a/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -138,7 +138,7 @@ class ModulesUninstallForm extends FormBase { $form['modules'] = []; // Only build the rest of the form if there are any modules available to - // uninstall; + // uninstall. if (empty($uninstallable)) { return $form; } diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 9133eb8aa10..44f44179f5a 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -140,7 +140,8 @@ class ThemeSettingsForm extends ConfigFormBase { $themes = $this->themeHandler->listInfo(); - // Default settings are defined in theme_get_setting() in includes/theme.inc + // Default settings are defined in theme_get_setting() in + // includes/theme.inc. if ($theme) { if (!$this->themeHandler->hasUi($theme)) { throw new NotFoundHttpException(); @@ -168,7 +169,7 @@ class ThemeSettingsForm extends ConfigFormBase { '#value' => $config_key, ]; - // Toggle settings + // Toggle settings. $toggles = [ 'node_user_picture' => $this->t('User pictures in posts'), 'comment_user_picture' => $this->t('User pictures in comments'), @@ -176,7 +177,7 @@ class ThemeSettingsForm extends ConfigFormBase { 'favicon' => $this->t('Shortcut icon'), ]; - // Some features are not always available + // Some features are not always available. $disabled = []; if (!user_picture_enabled()) { $disabled['toggle_node_user_picture'] = TRUE; diff --git a/core/modules/system/src/Hook/SystemThemeHooks.php b/core/modules/system/src/Hook/SystemThemeHooks.php new file mode 100644 index 00000000000..728a02f7498 --- /dev/null +++ b/core/modules/system/src/Hook/SystemThemeHooks.php @@ -0,0 +1,138 @@ +<?php + +namespace Drupal\system\Hook; + +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for system. + */ +class SystemThemeHooks { + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_html')] + public function themeSuggestionsHtml(array $variables): array { + $path_args = explode('/', trim(\Drupal::service('path.current')->getPath(), '/')); + return theme_get_suggestions($path_args, 'html'); + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_page')] + public function themeSuggestionsPage(array $variables): array { + $path_args = explode('/', trim(\Drupal::service('path.current')->getPath(), '/')); + $suggestions = theme_get_suggestions($path_args, 'page'); + $supported_http_error_codes = [ + 401, + 403, + 404, + ]; + $exception = \Drupal::requestStack()->getCurrentRequest()->attributes->get('exception'); + if ($exception instanceof HttpExceptionInterface && in_array($exception->getStatusCode(), $supported_http_error_codes, TRUE)) { + $suggestions[] = 'page__4xx'; + $suggestions[] = 'page__' . $exception->getStatusCode(); + } + return $suggestions; + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_maintenance_page')] + public function themeSuggestionsMaintenancePage(array $variables): array { + $suggestions = []; + // Dead databases will show error messages so supplying this template will + // allow themers to override the page and the content completely. + $offline = defined('MAINTENANCE_MODE'); + try { + \Drupal::service('path.matcher')->isFrontPage(); + } + catch (\Exception) { + // The database is not yet available. + $offline = TRUE; + } + if ($offline) { + $suggestions[] = 'maintenance_page__offline'; + } + return $suggestions; + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_region')] + public function themeSuggestionsRegion(array $variables): array { + $suggestions = []; + if (!empty($variables['elements']['#region'])) { + $suggestions[] = 'region__' . $variables['elements']['#region']; + } + return $suggestions; + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_field')] + public function themeSuggestionsField(array $variables): array { + $suggestions = []; + $element = $variables['element']; + $suggestions[] = 'field__' . $element['#field_type']; + $suggestions[] = 'field__' . $element['#field_name']; + $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#bundle']; + $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#field_name']; + $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#field_name'] . '__' . $element['#bundle']; + return $suggestions; + } + + /** + * @} End of "defgroup authorize". + */ + + /** + * Implements hook_preprocess_HOOK() for block templates. + */ + #[Hook('preprocess_block')] + public function preprocessBlock(&$variables): void { + switch ($variables['base_plugin_id']) { + case 'system_branding_block': + $variables['site_logo'] = ''; + if ($variables['content']['site_logo']['#access'] && $variables['content']['site_logo']['#uri']) { + $variables['site_logo'] = $variables['content']['site_logo']['#uri']; + } + $variables['site_name'] = ''; + if ($variables['content']['site_name']['#access'] && $variables['content']['site_name']['#markup']) { + $variables['site_name'] = $variables['content']['site_name']['#markup']; + } + $variables['site_slogan'] = ''; + if ($variables['content']['site_slogan']['#access'] && $variables['content']['site_slogan']['#markup']) { + $variables['site_slogan'] = [ + '#markup' => $variables['content']['site_slogan']['#markup'], + ]; + } + break; + } + } + + /** + * Implements hook_preprocess_toolbar(). + */ + #[Hook('preprocess_toolbar')] + public function preprocessToolbar(array &$variables, $hook, $info): void { + // When Claro is the admin theme, Claro overrides the active theme's if that + // active theme is not Claro. Because of these potential overrides, the + // toolbar cache should be invalidated any time the default or admin theme + // changes. + $variables['#cache']['tags'][] = 'config:system.theme'; + // If Claro is the admin theme but not the active theme, still include + // Claro's toolbar preprocessing. + if (_system_is_claro_admin_and_not_active()) { + require_once DRUPAL_ROOT . '/core/themes/claro/claro.theme'; + claro_preprocess_toolbar($variables, $hook, $info); + } + } + +} diff --git a/core/modules/system/src/SystemManager.php b/core/modules/system/src/SystemManager.php index 43a53fe0542..563188e017f 100644 --- a/core/modules/system/src/SystemManager.php +++ b/core/modules/system/src/SystemManager.php @@ -120,7 +120,7 @@ class SystemManager { * An array of system requirements. */ public function listRequirements() { - // Load .install files + // Load .install files. include_once DRUPAL_ROOT . '/core/includes/install.inc'; drupal_load_updates(); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0fbcf9b6c1f..8fac07911e9 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -9,7 +9,6 @@ use Drupal\Core\Extension\Extension; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; /** * Disabled option on forms and settings. @@ -61,81 +60,6 @@ function system_hook_info(): array { } /** - * Implements hook_theme_suggestions_HOOK(). - */ -function system_theme_suggestions_html(array $variables): array { - $path_args = explode('/', trim(\Drupal::service('path.current')->getPath(), '/')); - return theme_get_suggestions($path_args, 'html'); -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function system_theme_suggestions_page(array $variables): array { - $path_args = explode('/', trim(\Drupal::service('path.current')->getPath(), '/')); - $suggestions = theme_get_suggestions($path_args, 'page'); - - $supported_http_error_codes = [401, 403, 404]; - $exception = \Drupal::requestStack()->getCurrentRequest()->attributes->get('exception'); - if ($exception instanceof HttpExceptionInterface && in_array($exception->getStatusCode(), $supported_http_error_codes, TRUE)) { - $suggestions[] = 'page__4xx'; - $suggestions[] = 'page__' . $exception->getStatusCode(); - } - - return $suggestions; -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function system_theme_suggestions_maintenance_page(array $variables): array { - $suggestions = []; - - // Dead databases will show error messages so supplying this template will - // allow themers to override the page and the content completely. - $offline = defined('MAINTENANCE_MODE'); - try { - \Drupal::service('path.matcher')->isFrontPage(); - } - catch (Exception) { - // The database is not yet available. - $offline = TRUE; - } - if ($offline) { - $suggestions[] = 'maintenance_page__offline'; - } - - return $suggestions; -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function system_theme_suggestions_region(array $variables): array { - $suggestions = []; - if (!empty($variables['elements']['#region'])) { - $suggestions[] = 'region__' . $variables['elements']['#region']; - } - return $suggestions; -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function system_theme_suggestions_field(array $variables): array { - $suggestions = []; - $element = $variables['element']; - - $suggestions[] = 'field__' . $element['#field_type']; - $suggestions[] = 'field__' . $element['#field_name']; - $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#bundle']; - $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#field_name']; - $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#field_name'] . '__' . $element['#bundle']; - - return $suggestions; -} - -/** * Prepares variables for the list of available bundles. * * Default template: entity-add-list.html.twig. @@ -307,34 +231,6 @@ function system_authorized_batch_process() { } /** - * @} End of "defgroup authorize". - */ - -/** - * Implements hook_preprocess_HOOK() for block templates. - */ -function system_preprocess_block(&$variables): void { - switch ($variables['base_plugin_id']) { - case 'system_branding_block': - $variables['site_logo'] = ''; - if ($variables['content']['site_logo']['#access'] && $variables['content']['site_logo']['#uri']) { - $variables['site_logo'] = $variables['content']['site_logo']['#uri']; - } - $variables['site_name'] = ''; - if ($variables['content']['site_name']['#access'] && $variables['content']['site_name']['#markup']) { - $variables['site_name'] = $variables['content']['site_name']['#markup']; - } - $variables['site_slogan'] = ''; - if ($variables['content']['site_slogan']['#access'] && $variables['content']['site_slogan']['#markup']) { - $variables['site_slogan'] = [ - '#markup' => $variables['content']['site_slogan']['#markup'], - ]; - } - break; - } -} - -/** * Checks the existence of the directory specified in $form_element. * * This function is called from the system_settings form to check all core @@ -478,21 +374,3 @@ function _system_is_claro_admin_and_not_active() { $active_theme = \Drupal::theme()->getActiveTheme()->getName(); return $active_theme !== 'claro' && $admin_theme === 'claro'; } - -/** - * Implements hook_preprocess_toolbar(). - */ -function system_preprocess_toolbar(array &$variables, $hook, $info): void { - // When Claro is the admin theme, Claro overrides the active theme's if that - // active theme is not Claro. Because of these potential overrides, the - // toolbar cache should be invalidated any time the default or admin theme - // changes. - $variables['#cache']['tags'][] = 'config:system.theme'; - - // If Claro is the admin theme but not the active theme, still include Claro's - // toolbar preprocessing. - if (_system_is_claro_admin_and_not_active()) { - require_once DRUPAL_ROOT . '/core/themes/claro/claro.theme'; - claro_preprocess_toolbar($variables, $hook, $info); - } -} diff --git a/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php b/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php index 24da9ebff84..aa4dc2e1a29 100644 --- a/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php +++ b/core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php @@ -111,7 +111,7 @@ class BatchTestCallbacks { // 'finished' callback. $batch_test_helper->stack("op 5 id $id"); $context['results'][5][] = $id; - // This test is to test finished > 1 + // This test is to test finished > 1. $context['finished'] = 3.14; } diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestOptionalContainerForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestOptionalContainerForm.php index 62157258cea..314d4675182 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestOptionalContainerForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestOptionalContainerForm.php @@ -37,7 +37,7 @@ class FormTestOptionalContainerForm extends FormBase { '#optional' => FALSE, ]; - // Non-empty containers + // Non-empty containers. $form['nonempty_optional'] = [ '#type' => 'container', '#attributes' => ['class' => ['nonempty_optional']], diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php index 637399b3638..cde0058a5db 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStorageForm.php @@ -34,7 +34,7 @@ class FormTestStorageForm extends FormBase { if ($form_state->isRebuilding()) { $form_state->setUserInput([]); } - // Initialize + // Initialize. $storage = $form_state->getStorage(); $session = $this->getRequest()->getSession(); if (empty($storage)) { @@ -42,7 +42,7 @@ class FormTestStorageForm extends FormBase { if (empty($user_input)) { $session->set('constructions', 0); } - // Put the initial thing into the storage + // Put the initial thing into the storage. $storage = [ 'thing' => [ 'title' => 'none', diff --git a/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php b/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php index 6de8e4ad185..b6b54647efa 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php @@ -446,7 +446,7 @@ class JavascriptStatesForm extends FormBase { '#title' => 'Textfield in details', ]; - // Select trigger + // Select trigger. $form['header_select'] = [ '#type' => 'html_tag', '#tag' => 'h3', diff --git a/core/modules/system/tests/modules/icon_test/config/schema/icon_test.schema.yml b/core/modules/system/tests/modules/icon_test/config/schema/icon_test.schema.yml index 113b165e50e..ed96b94968d 100644 --- a/core/modules/system/tests/modules/icon_test/config/schema/icon_test.schema.yml +++ b/core/modules/system/tests/modules/icon_test/config/schema/icon_test.schema.yml @@ -8,14 +8,12 @@ icon.icon_pack_options.test_path: type: integer label: 'Width' constraints: - Range: - min: 0 + PositiveOrZero: ~ height: type: integer label: 'Height' constraints: - Range: - min: 0 + PositiveOrZero: ~ icon.icon_pack_options.test_svg: type: mapping @@ -27,8 +25,7 @@ icon.icon_pack_options.test_svg: type: integer label: 'Size' constraints: - Range: - min: 0 + PositiveOrZero: ~ icon.icon_pack_options.test_svg_sprite: type: mapping @@ -40,14 +37,12 @@ icon.icon_pack_options.test_svg_sprite: type: integer label: 'Width' constraints: - Range: - min: 0 + PositiveOrZero: ~ height: type: integer label: 'Height' constraints: - Range: - min: 0 + PositiveOrZero: ~ alt: type: label label: 'Alt' @@ -62,14 +57,12 @@ icon.icon_pack_options.test_settings: type: integer label: 'Width' constraints: - Range: - min: 0 + PositiveOrZero: ~ height: type: integer label: 'Height' constraints: - Range: - min: 0 + PositiveOrZero: ~ title: type: label label: 'Title' diff --git a/core/modules/system/tests/modules/layout_test/layout_test.module b/core/modules/system/tests/modules/layout_test/layout_test.module deleted file mode 100644 index 18459369b0a..00000000000 --- a/core/modules/system/tests/modules/layout_test/layout_test.module +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -/** - * @file - * Provides hook implementations for Layout Test. - */ - -declare(strict_types=1); - -/** - * Implements hook_preprocess_HOOK() for layout templates. - */ -function template_preprocess_layout_test_2col(&$variables): void { - $variables['region_attributes']['left']->addClass('class-added-by-preprocess'); -} diff --git a/core/modules/system/tests/modules/layout_test/src/Hook/LayoutTestThemeHooks.php b/core/modules/system/tests/modules/layout_test/src/Hook/LayoutTestThemeHooks.php new file mode 100644 index 00000000000..35774e5de4b --- /dev/null +++ b/core/modules/system/tests/modules/layout_test/src/Hook/LayoutTestThemeHooks.php @@ -0,0 +1,22 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\layout_test\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for layout_test. + */ +class LayoutTestThemeHooks { + + /** + * Implements hook_preprocess_HOOK() for layout templates. + */ + #[Hook('preprocess_layout_test_2col')] + public function templatePreprocessLayoutTest2col(&$variables): void { + $variables['region_attributes']['left']->addClass('class-added-by-preprocess'); + } + +} diff --git a/core/modules/system/tests/modules/module_test/module_test.file.inc b/core/modules/system/tests/modules/module_test/module_test.file.inc deleted file mode 100644 index 5ba5f5614ca..00000000000 --- a/core/modules/system/tests/modules/module_test/module_test.file.inc +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -/** - * @file - * Install, update and uninstall functions for the module_test module. - * - * Provides a hook to test \Drupal::moduleHandler()->getImplementationInfo() - * loading includes. - */ - -declare(strict_types=1); - -/** - * Implements hook_test_hook(). - */ -function module_test_test_hook(): array { - return ['module_test' => 'success!']; -} - -/** - * Implements hook_test_reset_implementations_hook(). - */ -function module_test_test_reset_implementations_hook(): string { - return __FUNCTION__; -} - -/** - * Implements hook_test_reset_implementations_alter(). - */ -function module_test_test_reset_implementations_alter(array &$data): void { - $data[] = __FUNCTION__; -} diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 35561f09c8a..b3f3e131a58 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -7,57 +7,6 @@ declare(strict_types=1); -use Drupal\Core\Extension\Extension; - -/** - * Implements hook_system_info_alter(). - * - * Manipulate module dependencies to test dependency chains. - */ -function module_test_system_info_alter(&$info, Extension $file, $type): void { - if (\Drupal::state()->get('module_test.dependency') == 'missing dependency') { - if ($file->getName() == 'dblog') { - // Make dblog module depend on config. - $info['dependencies'][] = 'config'; - } - elseif ($file->getName() == 'config') { - // Make config module depend on a non-existing module. - $info['dependencies'][] = 'foo'; - } - } - elseif (\Drupal::state()->get('module_test.dependency') == 'dependency') { - if ($file->getName() == 'dblog') { - // Make dblog module depend on config. - $info['dependencies'][] = 'config'; - } - elseif ($file->getName() == 'config') { - // Make config module depend on help module. - $info['dependencies'][] = 'help'; - } - elseif ($file->getName() == 'entity_test') { - // Make entity test module depend on help module. - $info['dependencies'][] = 'help'; - } - } - elseif (\Drupal::state()->get('module_test.dependency') == 'version dependency') { - if ($file->getName() == 'dblog') { - // Make dblog module depend on config. - $info['dependencies'][] = 'config'; - } - elseif ($file->getName() == 'config') { - // Make config module depend on a specific version of help module. - $info['dependencies'][] = 'help (1.x)'; - } - elseif ($file->getName() == 'help') { - // Set help module to a version compatible with the above. - $info['version'] = '8.x-1.0'; - } - } - if ($file->getName() == 'stark' && $type == 'theme') { - $info['regions']['test_region'] = 'Test region'; - } -} - /** * Implements hook_hook_info(). */ @@ -77,21 +26,3 @@ function module_test_load($param) { $result = \Drupal::moduleHandler()->invokeAll('test_hook'); return $result[$param]; } - -/** - * Implements hook_modules_installed(). - */ -function module_test_modules_installed($modules): void { - // Record the ordered list of modules that were passed in to this hook so we - // can check that the modules were enabled in the correct sequence. - \Drupal::state()->set('module_test.install_order', $modules); -} - -/** - * Implements hook_modules_uninstalled(). - */ -function module_test_modules_uninstalled($modules): void { - // Record the ordered list of modules that were passed in to this hook so we - // can check that the modules were uninstalled in the correct sequence. - \Drupal::state()->set('module_test.uninstall_order', $modules); -} diff --git a/core/modules/system/tests/modules/module_test/src/Hook/ModuleTestFileThemeHooks.php b/core/modules/system/tests/modules/module_test/src/Hook/ModuleTestFileThemeHooks.php new file mode 100644 index 00000000000..381a9458260 --- /dev/null +++ b/core/modules/system/tests/modules/module_test/src/Hook/ModuleTestFileThemeHooks.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\module_test\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for module_test. + */ +class ModuleTestFileThemeHooks { + + /** + * Implements hook_test_hook(). + */ + #[Hook('test_hook')] + public function testHook(): array { + return [ + 'module_test' => 'success!', + ]; + } + + /** + * Implements hook_test_reset_implementations_hook(). + */ + #[Hook('test_reset_implementations_hook')] + public function testResetImplementationsHook(): string { + return 'module_test_test_reset_implementations_hook'; + } + + /** + * Implements hook_test_reset_implementations_alter(). + */ + #[Hook('test_reset_implementations_alter')] + public function testResetImplementationsAlter(array &$data): void { + $data[] = 'module_test_test_reset_implementations_alter'; + } + +} diff --git a/core/modules/system/tests/modules/module_test/src/Hook/ModuleTestThemeHooks.php b/core/modules/system/tests/modules/module_test/src/Hook/ModuleTestThemeHooks.php new file mode 100644 index 00000000000..a34adbe620c --- /dev/null +++ b/core/modules/system/tests/modules/module_test/src/Hook/ModuleTestThemeHooks.php @@ -0,0 +1,85 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\module_test\Hook; + +use Drupal\Core\Extension\Extension; +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for module_test. + */ +class ModuleTestThemeHooks { + + /** + * Implements hook_system_info_alter(). + * + * Manipulate module dependencies to test dependency chains. + */ + #[Hook('system_info_alter')] + public function systemInfoAlter(&$info, Extension $file, $type): void { + if (\Drupal::state()->get('module_test.dependency') == 'missing dependency') { + if ($file->getName() == 'dblog') { + // Make dblog module depend on config. + $info['dependencies'][] = 'config'; + } + elseif ($file->getName() == 'config') { + // Make config module depend on a non-existing module. + $info['dependencies'][] = 'foo'; + } + } + elseif (\Drupal::state()->get('module_test.dependency') == 'dependency') { + if ($file->getName() == 'dblog') { + // Make dblog module depend on config. + $info['dependencies'][] = 'config'; + } + elseif ($file->getName() == 'config') { + // Make config module depend on help module. + $info['dependencies'][] = 'help'; + } + elseif ($file->getName() == 'entity_test') { + // Make entity test module depend on help module. + $info['dependencies'][] = 'help'; + } + } + elseif (\Drupal::state()->get('module_test.dependency') == 'version dependency') { + if ($file->getName() == 'dblog') { + // Make dblog module depend on config. + $info['dependencies'][] = 'config'; + } + elseif ($file->getName() == 'config') { + // Make config module depend on a specific version of help module. + $info['dependencies'][] = 'help (1.x)'; + } + elseif ($file->getName() == 'help') { + // Set help module to a version compatible with the above. + $info['version'] = '8.x-1.0'; + } + } + if ($file->getName() == 'stark' && $type == 'theme') { + $info['regions']['test_region'] = 'Test region'; + } + } + + /** + * Implements hook_modules_installed(). + */ + #[Hook('modules_installed')] + public function modulesInstalled($modules): void { + // Record the ordered list of modules that were passed in to this hook so we + // can check that the modules were enabled in the correct sequence. + \Drupal::state()->set('module_test.install_order', $modules); + } + + /** + * Implements hook_modules_uninstalled(). + */ + #[Hook('modules_uninstalled')] + public function modulesUninstalled($modules): void { + // Record the ordered list of modules that were passed in to this hook so we + // can check that the modules were uninstalled in the correct sequence. + \Drupal::state()->set('module_test.uninstall_order', $modules); + } + +} diff --git a/core/modules/system/tests/modules/olivero_test/olivero_test.module b/core/modules/system/tests/modules/olivero_test/olivero_test.module deleted file mode 100644 index 5d697759254..00000000000 --- a/core/modules/system/tests/modules/olivero_test/olivero_test.module +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -/** - * @file - * Functions to support testing the Olivero theme. - */ - -declare(strict_types=1); - -/** - * Implements hook_preprocess_field_multiple_value_form(). - */ -function olivero_test_preprocess_field_multiple_value_form(&$variables): void { - // Set test multiple value form field to disabled - if ($variables["element"]["#field_name"] === "field_multiple_value_form_field") { - $variables['element']['#disabled'] = TRUE; - } -} - -/** - * Implements hook_preprocess_html(). - */ -function olivero_test_preprocess_html(&$variables): void { - $variables['#attached']['library'][] = 'olivero_test/log-errors'; -} diff --git a/core/modules/system/tests/modules/olivero_test/src/Hook/OliveroTestThemeHooks.php b/core/modules/system/tests/modules/olivero_test/src/Hook/OliveroTestThemeHooks.php new file mode 100644 index 00000000000..1a5f7247a74 --- /dev/null +++ b/core/modules/system/tests/modules/olivero_test/src/Hook/OliveroTestThemeHooks.php @@ -0,0 +1,33 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\olivero_test\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for olivero_test. + */ +class OliveroTestThemeHooks { + + /** + * Implements hook_preprocess_field_multiple_value_form(). + */ + #[Hook('preprocess_field_multiple_value_form')] + public function preprocessFieldMultipleValueForm(&$variables): void { + // Set test multiple value form field to disabled. + if ($variables["element"]["#field_name"] === "field_multiple_value_form_field") { + $variables['element']['#disabled'] = TRUE; + } + } + + /** + * Implements hook_preprocess_html(). + */ + #[Hook('preprocess_html')] + public function preprocessHtml(&$variables): void { + $variables['#attached']['library'][] = 'olivero_test/log-errors'; + } + +} diff --git a/core/modules/system/tests/modules/pager_test/pager_test.module b/core/modules/system/tests/modules/pager_test/pager_test.module deleted file mode 100644 index e4556eddba3..00000000000 --- a/core/modules/system/tests/modules/pager_test/pager_test.module +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/** - * @file - * Hook implementations for this module. - */ - -declare(strict_types=1); - -/** - * Implements hook_preprocess_HOOK(). - */ -function pager_test_preprocess_pager(&$variables): void { - // Nothing to do if there is only one page. - $element = $variables['pager']['#element']; - /** @var \Drupal\Core\Pager\PagerManagerInterface $pager_manager */ - $pager_manager = \Drupal::service('pager.manager'); - $pager = $pager_manager->getPager($element); - - // Nothing to do if there is no pager. - if (!isset($pager)) { - return; - } - - // Nothing to do if there is only one page. - if ($pager->getTotalPages() <= 1) { - return; - } - - foreach ($variables['items']['pages'] as &$pager_item) { - $pager_item['attributes']['pager-test'] = 'yes'; - $pager_item['attributes']->addClass('lizards'); - } - unset($pager_item); - - foreach (['first', 'previous', 'next', 'last'] as $special_pager_item) { - if (isset($variables['items'][$special_pager_item])) { - $variables['items'][$special_pager_item]['attributes']->addClass('lizards'); - $variables['items'][$special_pager_item]['attributes']['pager-test'] = $special_pager_item; - } - } -} diff --git a/core/modules/system/tests/modules/pager_test/src/Hook/PagerTestThemeHooks.php b/core/modules/system/tests/modules/pager_test/src/Hook/PagerTestThemeHooks.php new file mode 100644 index 00000000000..ae72036a552 --- /dev/null +++ b/core/modules/system/tests/modules/pager_test/src/Hook/PagerTestThemeHooks.php @@ -0,0 +1,50 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\pager_test\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for pager_test. + */ +class PagerTestThemeHooks { + + /** + * Implements hook_preprocess_HOOK(). + */ + #[Hook('preprocess_pager')] + public function preprocessPager(&$variables): void { + // Nothing to do if there is only one page. + $element = $variables['pager']['#element']; + /** @var \Drupal\Core\Pager\PagerManagerInterface $pager_manager */ + $pager_manager = \Drupal::service('pager.manager'); + $pager = $pager_manager->getPager($element); + // Nothing to do if there is no pager. + if (!isset($pager)) { + return; + } + // Nothing to do if there is only one page. + if ($pager->getTotalPages() <= 1) { + return; + } + foreach ($variables['items']['pages'] as &$pager_item) { + $pager_item['attributes']['pager-test'] = 'yes'; + $pager_item['attributes']->addClass('lizards'); + } + unset($pager_item); + foreach ([ + 'first', + 'previous', + 'next', + 'last', + ] as $special_pager_item) { + if (isset($variables['items'][$special_pager_item])) { + $variables['items'][$special_pager_item]['attributes']->addClass('lizards'); + $variables['items'][$special_pager_item]['attributes']['pager-test'] = $special_pager_item; + } + } + } + +} diff --git a/core/modules/system/tests/modules/router_test_directory/router_test.module b/core/modules/system/tests/modules/router_test_directory/router_test.module deleted file mode 100644 index 2158075059c..00000000000 --- a/core/modules/system/tests/modules/router_test_directory/router_test.module +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -/** - * @file - * Test module. - */ - -declare(strict_types=1); - -use Drupal\Core\Url; - -/** - * Implements hook_preprocess_HOOK(). - * - * Performs an operation that calls the RouteProvider's collection method - * during an exception page view. (which is rendered during a subrequest.) - * - * @see \Drupal\FunctionalTests\Routing\RouteCachingQueryAlteredTest - */ -function router_test_preprocess_page(&$variables): void { - $request = \Drupal::request(); - if ($request->getPathInfo() === '/router-test/rejects-query-strings') { - // Create a URL from the request, e.g. for a breadcrumb or other contextual - // information. - Url::createFromRequest($request); - } -} diff --git a/core/modules/system/tests/modules/router_test_directory/src/Hook/RouterTestThemeHooks.php b/core/modules/system/tests/modules/router_test_directory/src/Hook/RouterTestThemeHooks.php new file mode 100644 index 00000000000..da642b8b13b --- /dev/null +++ b/core/modules/system/tests/modules/router_test_directory/src/Hook/RouterTestThemeHooks.php @@ -0,0 +1,33 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\router_test\Hook; + +use Drupal\Core\Url; +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for router_test. + */ +class RouterTestThemeHooks { + + /** + * Implements hook_preprocess_HOOK(). + * + * Performs an operation that calls the RouteProvider's collection method + * during an exception page view. (which is rendered during a subrequest.) + * + * @see \Drupal\FunctionalTests\Routing\RouteCachingQueryAlteredTest + */ + #[Hook('preprocess_page')] + public function preprocessPage(&$variables): void { + $request = \Drupal::request(); + if ($request->getPathInfo() === '/router-test/rejects-query-strings') { + // Create a URL from the request, e.g. for a breadcrumb or other contextual + // information. + Url::createFromRequest($request); + } + } + +} diff --git a/core/modules/system/tests/modules/theme_region_test/src/Hook/ThemeRegionTestThemeHooks.php b/core/modules/system/tests/modules/theme_region_test/src/Hook/ThemeRegionTestThemeHooks.php new file mode 100644 index 00000000000..5cff4c19531 --- /dev/null +++ b/core/modules/system/tests/modules/theme_region_test/src/Hook/ThemeRegionTestThemeHooks.php @@ -0,0 +1,24 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\theme_region_test\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for theme_region_test. + */ +class ThemeRegionTestThemeHooks { + + /** + * Implements hook_preprocess_HOOK() for region templates. + */ + #[Hook('preprocess_region')] + public function preprocessRegion(&$variables): void { + if ($variables['region'] == 'sidebar_first') { + $variables['attributes']['class'][] = 'new_class'; + } + } + +} diff --git a/core/modules/system/tests/modules/theme_region_test/theme_region_test.module b/core/modules/system/tests/modules/theme_region_test/theme_region_test.module deleted file mode 100644 index 5e9dc670a47..00000000000 --- a/core/modules/system/tests/modules/theme_region_test/theme_region_test.module +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/** - * @file - * Provides hook implementations for testing purposes. - */ - -declare(strict_types=1); - -/** - * Implements hook_preprocess_HOOK() for region templates. - */ -function theme_region_test_preprocess_region(&$variables): void { - if ($variables['region'] == 'sidebar_first') { - $variables['attributes']['class'][] = 'new_class'; - } -} diff --git a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks1.php b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks1.php new file mode 100644 index 00000000000..ddd0e7efc39 --- /dev/null +++ b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks1.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\theme_test\Hook; + +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for theme_test. + */ +class ThemeTestThemeHooks1 { + + /** + * Implements hook_preprocess_HOOK() for HTML document templates. + */ + #[Hook('preprocess_html')] + public function preprocessHtml(&$variables): void { + $variables['html_attributes']['theme_test_html_attribute'] = 'theme test html attribute value'; + $variables['attributes']['theme_test_body_attribute'] = 'theme test body attribute value'; + $variables['attributes']['theme_test_page_variable'] = 'Page variable is an array.'; + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_theme_test_preprocess_suggestions')] + public function themeSuggestionsThemeTestPreprocessSuggestions($variables): array { + return [ + 'theme_test_preprocess_suggestions__' . $variables['foo'], + ]; + } + + /** + * Implements hook_preprocess_HOOK(). + */ + #[Hook('preprocess_theme_test_preprocess_suggestions')] + public function preprocessThemeTestPreprocessSuggestions(&$variables): void { + $variables['foo'] = 'Theme hook implementor=theme_theme_test_preprocess_suggestions().'; + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_theme_test_suggestion_provided')] + public function themeSuggestionsThemeTestSuggestionProvided(array $variables): array { + return [ + 'theme_test_suggestion_provided__foo', + ]; + } + + /** + * Implements hook_theme_suggestions_HOOK(). + */ + #[Hook('theme_suggestions_node')] + public function themeSuggestionsNode(array $variables): array { + $xss = '<script type="text/javascript">alert(\'yo\');</script>'; + $suggestions[] = 'node__' . $xss; + return $suggestions; + } + +} diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 72c92352b61..b987fb0d40f 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -8,30 +8,6 @@ declare(strict_types=1); /** - * Implements hook_preprocess_HOOK() for HTML document templates. - */ -function theme_test_preprocess_html(&$variables): void { - $variables['html_attributes']['theme_test_html_attribute'] = 'theme test html attribute value'; - $variables['attributes']['theme_test_body_attribute'] = 'theme test body attribute value'; - - $variables['attributes']['theme_test_page_variable'] = 'Page variable is an array.'; -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function theme_test_theme_suggestions_theme_test_preprocess_suggestions($variables): array { - return ['theme_test_preprocess_suggestions__' . $variables['foo']]; -} - -/** - * Implements hook_preprocess_HOOK(). - */ -function theme_test_preprocess_theme_test_preprocess_suggestions(&$variables): void { - $variables['foo'] = 'Theme hook implementor=theme_theme_test_preprocess_suggestions().'; -} - -/** * Prepares variables for test render element templates. * * Default template: theme-test-render-element.html.twig. @@ -45,23 +21,6 @@ function template_preprocess_theme_test_render_element(&$variables): void { } /** - * Implements hook_theme_suggestions_HOOK(). - */ -function theme_test_theme_suggestions_theme_test_suggestion_provided(array $variables): array { - return ['theme_test_suggestion_provided__foo']; -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function theme_test_theme_suggestions_node(array $variables): array { - $xss = '<script type="text/javascript">alert(\'yo\');</script>'; - $suggestions[] = 'node__' . $xss; - - return $suggestions; -} - -/** * Implements template_preprocess_HOOK() for theme_test_registered_by_module. */ function template_preprocess_theme_test_registered_by_module(): void { diff --git a/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php index 60b7c12b5a1..72e95946a5d 100644 --- a/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php +++ b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php @@ -28,7 +28,7 @@ class SelectTableSortDefaultTest extends DatabaseTestBase { ['field' => 'Task ID', 'sort' => 'asc', 'first' => 'eat', 'last' => 'perform at superbowl'], ['field' => 'Task', 'sort' => 'asc', 'first' => 'code', 'last' => 'sleep'], ['field' => 'Task', 'sort' => 'desc', 'first' => 'sleep', 'last' => 'code'], - // More elements here + // More elements here. ]; @@ -56,7 +56,7 @@ class SelectTableSortDefaultTest extends DatabaseTestBase { ['field' => 'Task ID', 'sort' => 'asc', 'first' => 'eat', 'last' => 'perform at superbowl'], ['field' => 'Task', 'sort' => 'asc', 'first' => 'code', 'last' => 'sleep'], ['field' => 'Task', 'sort' => 'desc', 'first' => 'sleep', 'last' => 'code'], - // More elements here + // More elements here. ]; diff --git a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php index fa6bda652de..61ea15323c1 100644 --- a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php +++ b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php @@ -77,7 +77,7 @@ class FileTransferTest extends BrowserTestBase { $this->_writeDirectory($base . DIRECTORY_SEPARATOR . $key, $file); } else { - // Just write the filename into the file + // Just write the filename into the file. file_put_contents($base . DIRECTORY_SEPARATOR . $file, $file); } } diff --git a/core/modules/system/tests/src/Functional/Form/ElementTest.php b/core/modules/system/tests/src/Functional/Form/ElementTest.php index 0ebf9e4ce77..294c4e2ec34 100644 --- a/core/modules/system/tests/src/Functional/Form/ElementTest.php +++ b/core/modules/system/tests/src/Functional/Form/ElementTest.php @@ -154,10 +154,10 @@ class ElementTest extends BrowserTestBase { * Tests the submit_button attribute. */ protected function testSubmitButtonAttribute(): void { - // Set the submit_button attribute to true + // Set the submit_button attribute to true. $this->drupalGet('form-test/submit-button-attribute'); $this->assertSession()->elementsCount('xpath', '//input[@type="submit"]', 1); - // Set the submit_button attribute to false + // Set the submit_button attribute to false. $this->drupalGet('form-test/submit-button-attribute/1'); $this->assertSession()->elementsCount('xpath', '//input[@type="button"]', 1); } diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php index f45e45e6159..c7cb67c72c7 100644 --- a/core/modules/system/tests/src/Functional/Form/FormTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormTest.php @@ -306,12 +306,12 @@ class FormTest extends BrowserTestBase { ]; $this->submitForm($edit, 'Submit'); // Verify that the error message is displayed with invalid token even when - // required fields are filled.' + // required fields are filled. $this->assertSession()->elementExists('xpath', '//div[contains(@class, "error")]'); $this->assertSession()->pageTextContains('The form has become outdated.'); $this->assertSession()->fieldValueEquals('integer_step', 5); - // Check a form with a URL field + // Check a form with a URL field. $this->drupalGet(Url::fromRoute('form_test.url')); $this->assertSession() ->elementExists('css', 'input[name="form_token"]') diff --git a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php index f2df8a91458..c7d6f6d7d2b 100644 --- a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php +++ b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php @@ -170,7 +170,7 @@ class LocalTasksTest extends BrowserTestBase { $this->assertEquals('Settings', $result[0]->getText(), 'The settings tab is active.'); $this->assertEquals('Derive 1', $result[1]->getText(), 'The derive1 tab is active.'); - // Ensures that the local tasks contains the proper 'provider key' + // Ensures that the local tasks contains the proper 'provider key'. $definitions = $this->container->get('plugin.manager.menu.local_task')->getDefinitions(); $this->assertEquals('menu_test', $definitions['menu_test.local_task_test_tasks_view']['provider']); $this->assertEquals('menu_test', $definitions['menu_test.local_task_test_tasks_edit']['provider']); diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php index 7f2d218388a..2a51e4b8de8 100644 --- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php +++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php @@ -142,7 +142,7 @@ class DependencyTest extends ModuleTestBase { $this->assertSession()->fieldEnabled('modules[system_no_module_version_dependency_test][enable]'); $this->assertSession()->fieldDisabled('modules[system_no_module_version_test][enable]'); - // Remove the version requirement from the dependency definition + // Remove the version requirement from the dependency definition. $info = [ 'type' => 'module', 'core_version_requirement' => '*', @@ -253,9 +253,8 @@ class DependencyTest extends ModuleTestBase { $this->resetAll(); $this->assertModules(['module_test'], TRUE); \Drupal::state()->set('module_test.dependency', 'dependency'); - // module_test creates a dependency chain: - // - dblog depends on config - // - config depends on help + // module_test creates a dependency chain: dblog depends on config which + // depends on help. $expected_order = ['help', 'config', 'dblog']; // Enable the modules through the UI, verifying that the dependency chain diff --git a/core/modules/system/tests/src/Functional/Pager/PagerTest.php b/core/modules/system/tests/src/Functional/Pager/PagerTest.php index 9d0cae26b41..3cbde95efb4 100644 --- a/core/modules/system/tests/src/Functional/Pager/PagerTest.php +++ b/core/modules/system/tests/src/Functional/Pager/PagerTest.php @@ -179,7 +179,7 @@ class PagerTest extends BrowserTestBase { // We loop through the page with the test data query parameters, and check // that the active page for each pager element has the expected page - // (1-indexed) and resulting query parameter + // (1-indexed) and resulting query parameter. foreach ($test_data as $data) { $input_query = str_replace(' ', '%20', $data['input_query']); $this->drupalGet($this->getAbsoluteUrl(parse_url($this->getUrl())['path'] . $input_query), ['external' => TRUE]); diff --git a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php index a3a89112afe..165fb692952 100644 --- a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php +++ b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php @@ -41,19 +41,19 @@ class UpcastingTest extends BrowserTestBase { $user = $this->drupalCreateUser(['access content']); $foo = 'bar'; - // paramconverter_test/test_user_node_foo/{user}/{node}/{foo} + // Test "paramconverter_test/test_user_node_foo/{user}/{node}/{foo}". $this->drupalGet("paramconverter_test/test_user_node_foo/" . $user->id() . '/' . $node->id() . "/$foo"); // Verify user and node upcast by entity name. $this->assertSession()->pageTextContains("user: {$user->label()}, node: {$node->label()}, foo: $foo"); - // paramconverter_test/test_node_user_user/{node}/{foo}/{user} - // options.parameters.foo.type = entity:user + // Test "paramconverter_test/test_node_user_user/{node}/{foo}/{user}" with + // "options.parameters.foo.type = entity:user". $this->drupalGet("paramconverter_test/test_node_user_user/" . $node->id() . "/" . $user->id() . "/" . $user->id()); // Verify foo converted to user as well. $this->assertSession()->pageTextContains("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}"); - // paramconverter_test/test_node_node_foo/{user}/{node}/{foo} - // options.parameters.user.type = entity:node + // Test "paramconverter_test/test_node_node_foo/{user}/{node}/{foo}" with + // "options.parameters.user.type = entity:node". $this->drupalGet("paramconverter_test/test_node_node_foo/" . $node->id() . "/" . $node->id() . "/$foo"); // Verify that user is upcast to node (rather than to user). $this->assertSession()->pageTextContains("user: {$node->label()}, node: {$node->label()}, foo: $foo"); @@ -65,8 +65,8 @@ class UpcastingTest extends BrowserTestBase { public function testSameTypes(): void { $node = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]); $parent = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]); - // paramconverter_test/node/{node}/set/parent/{parent} - // options.parameters.parent.type = entity:node + // Test "paramconverter_test/node/{node}/set/parent/{parent}" with + // "options.parameters.parent.type = entity:node". $this->drupalGet("paramconverter_test/node/" . $node->id() . "/set/parent/" . $parent->id()); $this->assertSession()->pageTextContains("Setting '" . $parent->getTitle() . "' as parent of '" . $node->getTitle() . "'."); } diff --git a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php index 0163c594a06..51d8d20713e 100644 --- a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php +++ b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php @@ -115,7 +115,7 @@ class AccessDeniedTest extends BrowserTestBase { $this->assertSession()->statusCodeEquals(403); $this->assertSession()->pageTextContains('Username'); - // Log back in, set the custom 403 page to /user/login and remove the block + // Log back in, set the custom 403 page to /user/login and remove the block. $this->drupalLogin($this->adminUser); $this->config('system.site')->set('page.403', '/user/login')->save(); $block->disable()->save(); diff --git a/core/modules/system/tests/src/Functional/System/PageTitleTest.php b/core/modules/system/tests/src/Functional/System/PageTitleTest.php index d225842a236..cf2a5a61512 100644 --- a/core/modules/system/tests/src/Functional/System/PageTitleTest.php +++ b/core/modules/system/tests/src/Functional/System/PageTitleTest.php @@ -126,7 +126,7 @@ class PageTitleTest extends BrowserTestBase { $this->assertSession()->titleEquals('Foo | Drupal'); $this->assertSession()->elementTextEquals('xpath', '//h1[@class="page-title"]', 'Foo'); - // Test forms + // Test forms. $this->drupalGet('form-test/object-builder'); $this->assertSession()->titleEquals('Test dynamic title | Drupal'); diff --git a/core/modules/system/tests/src/FunctionalJavascript/Form/ElementsTableSelectTest.php b/core/modules/system/tests/src/FunctionalJavascript/Form/ElementsTableSelectTest.php index a41129b9cff..10ffd2523d3 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/Form/ElementsTableSelectTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/Form/ElementsTableSelectTest.php @@ -51,7 +51,7 @@ class ElementsTableSelectTest extends WebDriverTestBase { $this->click($row); $this->assertSession()->assertWaitOnAjaxRequest(); $page->hasCheckedField($row); - // Check other rows are not checked + // Check other rows are not checked. for ($j = 1; $j <= 3; $j++) { if ($j == $i) { continue; diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php index 9839fc3edd4..462bf5a9e67 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -96,7 +96,7 @@ class OffCanvasTest extends OffCanvasTestBase { $page->clickLink('Display more links!'); $this->waitForOffCanvasToOpen(); $web_assert->linkExists('Off_canvas link!'); - // Click off-canvas link inside off-canvas dialog + // Click off-canvas link inside off-canvas dialog. $page->clickLink('Off_canvas link!'); $this->waitForOffCanvasToOpen(); $web_assert->elementTextContains('css', '.ui-dialog[aria-describedby="drupal-off-canvas"]', 'Thing 2 says hello'); @@ -109,7 +109,7 @@ class OffCanvasTest extends OffCanvasTestBase { $page->clickLink('Display more links!'); $this->waitForOffCanvasToOpen(); $web_assert->linkExists('Off_canvas link!'); - // Click off-canvas link inside off-canvas dialog + // Click off-canvas link inside off-canvas dialog. $page->clickLink('Off_canvas link!'); $this->waitForOffCanvasToOpen(); $web_assert->elementTextContains('css', '.ui-dialog[aria-describedby="drupal-off-canvas"]', 'Thing 2 says hello'); diff --git a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php index b8b18a5c9ba..9a69e563f01 100644 --- a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php +++ b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php @@ -27,8 +27,7 @@ class MigrateSystemConfigurationTest extends MigrateDrupal7TestBase { 'system.authorize' => [], 'system.cron' => [ 'threshold' => [ - // Auto-run is not handled by the migration. - // 'autorun' => 0, + // Auto-run is not handled by the migration, so ignore "'autorun' => 0". 'requirements_warning' => 172800, 'requirements_error' => 1209600, ], |