summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/system
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/system')
-rw-r--r--core/modules/system/css/components/position-container.module.css8
-rw-r--r--core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php2
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php12
-rw-r--r--core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php2
-rw-r--r--core/modules/system/system.libraries.yml1
-rw-r--r--core/modules/system/system.module10
-rw-r--r--core/modules/system/system.post_update.php2
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gzbin162581 -> 162168 bytes
-rw-r--r--core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gzbin596855 -> 596593 bytes
-rw-r--r--core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php5
-rw-r--r--core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php5
-rw-r--r--core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml1
-rw-r--r--core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php38
-rw-r--r--core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php6
-rw-r--r--core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php6
-rw-r--r--core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php4
-rw-r--r--core/modules/system/tests/modules/requirements1_test/requirements1_test.install2
-rw-r--r--core/modules/system/tests/modules/session_test/session_test.routing.yml22
-rw-r--r--core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php35
-rw-r--r--core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php127
-rw-r--r--core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php4
-rw-r--r--core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php2
-rw-r--r--core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php59
-rw-r--r--core/modules/system/tests/modules/update_script_test/update_script_test.install42
-rw-r--r--core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php33
-rw-r--r--core/modules/system/tests/modules/update_test_schema/update_test_schema.install19
-rw-r--r--core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php6
-rw-r--r--core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php5
-rw-r--r--core/modules/system/tests/src/Functional/Session/LegacySessionTest.php44
-rw-r--r--core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php21
-rw-r--r--core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php7
31 files changed, 327 insertions, 203 deletions
diff --git a/core/modules/system/css/components/position-container.module.css b/core/modules/system/css/components/position-container.module.css
deleted file mode 100644
index ae209f3aa61..00000000000
--- a/core/modules/system/css/components/position-container.module.css
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * @file
- * Contain positioned elements.
- */
-
-.position-container {
- position: relative;
-}
diff --git a/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php b/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php
index c9250047f1f..777efab6b0c 100644
--- a/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php
+++ b/core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php
@@ -23,7 +23,7 @@ class AccessRouteAlterSubscriber implements EventSubscriberInterface {
}
/**
- * Adds _access_admin_menu_block_page requirement to routes pointing to SystemController::systemAdminMenuBlockPage.
+ * Adds requirements to some System Controller routes.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The event to process.
diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
index 670fbc06cf7..ccd9725e821 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
@@ -439,9 +439,6 @@ class GDToolkit extends ImageToolkitBase {
IMG_AVIF => 'AVIF',
];
$supported_formats = array_filter($check_formats, fn($type) => imagetypes() & $type, ARRAY_FILTER_USE_KEY);
- if (isset($supported_formats[IMG_AVIF]) && !$this->checkAvifSupport()) {
- unset($supported_formats[IMG_AVIF]);
- }
$unsupported_formats = array_diff_key($check_formats, $supported_formats);
$descriptions = [];
@@ -556,7 +553,7 @@ class GDToolkit extends ImageToolkitBase {
* @return bool
* TRUE if AVIF is fully supported, FALSE otherwise.
*/
- protected function checkAvifSupport(): bool {
+ protected static function checkAvifSupport(): bool {
static $supported = NULL;
if ($supported !== NULL) {
@@ -578,13 +575,16 @@ class GDToolkit extends ImageToolkitBase {
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
*/
protected static function supportedTypes() {
- return [
+ $types = [
IMAGETYPE_PNG,
IMAGETYPE_JPEG,
IMAGETYPE_GIF,
IMAGETYPE_WEBP,
- IMAGETYPE_AVIF,
];
+ if (static::checkAvifSupport()) {
+ $types[] = IMAGETYPE_AVIF;
+ }
+ return $types;
}
}
diff --git a/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php b/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php
index ee1550984f7..2fbfd980d34 100644
--- a/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php
+++ b/core/modules/system/src/Plugin/migrate/process/d6/SystemUpdate7000.php
@@ -16,7 +16,7 @@ class SystemUpdate7000 extends ProcessPluginBase {
/**
* {@inheritdoc}
*
- * Rename blog and forum permissions to be consistent with other content types.
+ * Makes blog and forum permissions to be consistent with other content types.
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$value = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $value);
diff --git a/core/modules/system/system.libraries.yml b/core/modules/system/system.libraries.yml
index 03baf83d3bb..af0eeea05d2 100644
--- a/core/modules/system/system.libraries.yml
+++ b/core/modules/system/system.libraries.yml
@@ -9,7 +9,6 @@ base:
css/components/hidden.module.css: { weight: -10 }
css/components/item-list.module.css: { weight: -10 }
css/components/js.module.css: { weight: -10 }
- css/components/position-container.module.css: { weight: -10 }
css/components/reset-appearance.module.css: { weight: -10 }
admin:
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index c7ed1808206..dbda1e1b6b4 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -223,7 +223,7 @@ function template_preprocess_entity_add_list(&$variables): void {
* Optional string to use as the page title once redirected to authorize.php.
*/
function system_authorized_init($callback, $file, $arguments = [], $page_title = NULL): void {
- @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
+ @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
$session = \Drupal::request()->getSession();
// First, figure out what file transfer backends the site supports, and put
@@ -255,7 +255,7 @@ function system_authorized_init($callback, $file, $arguments = [], $page_title =
* @see system_authorized_init()
*/
function system_authorized_get_url(array $options = []) {
- @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
+ @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
// core/authorize.php is an unrouted URL, so using the base: scheme is
// the correct usage for this case.
@@ -275,7 +275,7 @@ function system_authorized_get_url(array $options = []) {
* The full URL for the authorize.php script with batch processing options.
*/
function system_authorized_batch_processing_url(array $options = []) {
- @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
+ @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
$options['query'] = ['batch' => '1'];
return system_authorized_get_url($options);
@@ -287,7 +287,7 @@ function system_authorized_batch_processing_url(array $options = []) {
* @see system_authorized_init()
*/
function system_authorized_run($callback, $file, $arguments = [], $page_title = NULL) {
- @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
+ @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
system_authorized_init($callback, $file, $arguments, $page_title);
return new RedirectResponse(system_authorized_get_url()->toString());
@@ -299,7 +299,7 @@ function system_authorized_run($callback, $file, $arguments = [], $page_title =
* @see batch_process()
*/
function system_authorized_batch_process() {
- @trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
+ @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
$finish_url = system_authorized_get_url();
$process_url = system_authorized_batch_processing_url();
diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php
index b1ed3dbe019..ce110e2c2f3 100644
--- a/core/modules/system/system.post_update.php
+++ b/core/modules/system/system.post_update.php
@@ -108,7 +108,7 @@ function system_post_update_remove_path_key(): void {
}
/**
- * Updates all entity_form_mode configuration entities to set description from empty string to null.
+ * Updates entity_form_mode descriptions from empty string to null.
*/
function system_post_update_convert_empty_description_entity_form_modes_to_null(array &$sandbox): void {
\Drupal::classResolver(ConfigEntityUpdater::class)
diff --git a/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz b/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz
index 5d8c9974469..077d0645ddc 100644
--- a/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz
+++ b/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz
Binary files differ
diff --git a/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz b/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz
index 423f49a1d40..5db0b3a5aae 100644
--- a/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz
+++ b/core/modules/system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz
Binary files differ
diff --git a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php
index 44308c3f6a9..33dba9b0bf6 100644
--- a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php
+++ b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsFormElement.php
@@ -7,13 +7,14 @@ namespace Drupal\element_info_test\Element;
use Drupal\Core\Render\Attribute\FormElement;
use Drupal\Core\Render\Element\FormElement as FormElementDeprecated;
+// @phpcs:disable
/**
* Provides render element that extends deprecated FormElement for testing.
- *
- * @phpstan-ignore class.extendsDeprecatedClass
*/
#[FormElement('deprecated_extends_form')]
+// @phpstan-ignore class.extendsDeprecatedClass
class DeprecatedExtendsFormElement extends FormElementDeprecated {
+// @phpcs:enable
/**
* {@inheritdoc}
diff --git a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php
index 514a3b01a4b..72a608bfc5e 100644
--- a/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php
+++ b/core/modules/system/tests/modules/element_info_test/src/Element/DeprecatedExtendsRenderElement.php
@@ -7,13 +7,14 @@ namespace Drupal\element_info_test\Element;
use Drupal\Core\Render\Attribute\RenderElement;
use Drupal\Core\Render\Element\RenderElement as RenderElementDeprecated;
+// @phpcs:disable
/**
* Provides render element that extends deprecated RenderElement for testing.
- *
- * @phpstan-ignore class.extendsDeprecatedClass
*/
#[RenderElement('deprecated_extends_render')]
+// @phpstan-ignore class.extendsDeprecatedClass
class DeprecatedExtendsRenderElement extends RenderElementDeprecated {
+// @phpcs:enable
/**
* {@inheritdoc}
diff --git a/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml b/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml
index 39d5a0f8125..25c13b4cd4c 100644
--- a/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml
+++ b/core/modules/system/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_group_by_empty_relationships.yml
@@ -77,6 +77,7 @@ display:
type: table
options:
grouping: { }
+ class: ''
row_class: ''
default_row_class: true
override: true
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
index 542c4e162e2..78328f9f8e4 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
@@ -35,32 +35,28 @@ class FormTestClickedButtonForm extends FormBase {
'#type' => 'textfield',
];
+ // Get button configurations, filter out NULL values.
+ $args = array_filter([$first, $second, $third]);
+
+ // Define button types for each argument.
+ $button_types = [
+ 's' => 'submit',
+ 'i' => 'image_button',
+ 'b' => 'button',
+ ];
+
// Loop through each path argument, adding buttons based on the information
// in the argument. For example, if the path is
// form-test/clicked-button/s/i/rb, then 3 buttons are added: a 'submit', an
// 'image_button', and a 'button' with #access=FALSE. This enables form.test
// to test a variety of combinations.
- $i = 0;
- $args = [$first, $second, $third];
- foreach ($args as $arg) {
- $name = 'button' . ++$i;
- // 's', 'b', or 'i' in the argument define the button type wanted.
- if (!is_string($arg)) {
- $type = NULL;
- }
- elseif (str_contains($arg, 's')) {
- $type = 'submit';
- }
- elseif (str_contains($arg, 'b')) {
- $type = 'button';
- }
- elseif (str_contains($arg, 'i')) {
- $type = 'image_button';
- }
- else {
- $type = NULL;
- }
- if (isset($type)) {
+ foreach ($args as $index => $arg) {
+ // Get the button type based on the index of the argument.
+ $type = $button_types[$arg] ?? NULL;
+ $name = 'button' . ($index + 1);
+
+ if ($type) {
+ // Define the button.
$form[$name] = [
'#type' => $type,
'#name' => $name,
diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
index 908d0d8d454..09dbf982cf7 100644
--- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
+++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/TestToolkit.php
@@ -253,7 +253,11 @@ class TestToolkit extends ImageToolkitBase {
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
*/
protected static function supportedTypes() {
- return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
+ $types = [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
+ if (\Drupal::keyValue('image_test')->get('avif_enabled', FALSE)) {
+ $types[] = IMAGETYPE_AVIF;
+ }
+ return $types;
}
/**
diff --git a/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php b/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
index 1cbb9e6b422..db923382a21 100644
--- a/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
+++ b/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
@@ -4,19 +4,19 @@ declare(strict_types=1);
namespace Drupal\module_test_oop_preprocess\Hook;
-use Drupal\Core\Hook\Attribute\Preprocess;
+use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for module_test_oop_preprocess.
*/
class ModuleTestOopPreprocessThemeHooks {
- #[Preprocess]
+ #[Hook('preprocess')]
public function rootPreprocess($arg): mixed {
return $arg;
}
- #[Preprocess('test')]
+ #[Hook('preprocess_test')]
public function preprocessTest($arg): mixed {
return $arg;
}
diff --git a/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php b/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php
index 1528a083981..6877871e2d2 100644
--- a/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php
+++ b/core/modules/system/tests/modules/render_placeholder_message_test/src/RenderPlaceholderMessageTestController.php
@@ -112,7 +112,9 @@ class RenderPlaceholderMessageTestController implements TrustedCallbackInterface
$reordered = [];
foreach ($placeholder_order as $placeholder) {
- $reordered[$placeholder] = $build['#attached']['placeholders'][$placeholder];
+ if (isset($build['#attached']['placeholders'][$placeholder])) {
+ $reordered[$placeholder] = $build['#attached']['placeholders'][$placeholder];
+ }
}
$build['#attached']['placeholders'] = $reordered;
diff --git a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
index 70767c16544..fb84be133cd 100644
--- a/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
+++ b/core/modules/system/tests/modules/requirements1_test/requirements1_test.install
@@ -9,6 +9,8 @@ declare(strict_types=1);
/**
* Implements hook_requirements().
+ *
+ * This tests the procedural implementations for this hook.
*/
function requirements1_test_requirements($phase): array {
$requirements = [];
diff --git a/core/modules/system/tests/modules/session_test/session_test.routing.yml b/core/modules/system/tests/modules/session_test/session_test.routing.yml
index fe85de11032..f11bd86b4d7 100644
--- a/core/modules/system/tests/modules/session_test/session_test.routing.yml
+++ b/core/modules/system/tests/modules/session_test/session_test.routing.yml
@@ -179,3 +179,25 @@ session_test.trigger_write_exception:
no_cache: TRUE
requirements:
_access: 'TRUE'
+
+session_test.legacy_get:
+ path: '/session-test/legacy-get'
+ defaults:
+ _title: 'Legacy session value'
+ _controller: '\Drupal\session_test\Controller\LegacySessionTestController::get'
+ options:
+ no_cache: TRUE
+ requirements:
+ _access: 'TRUE'
+
+session_test.legacy_set:
+ path: '/session-test/legacy-set/{test_value}'
+ defaults:
+ _title: 'Set legacy session value'
+ _controller: '\Drupal\session_test\Controller\LegacySessionTestController::set'
+ options:
+ no_cache: TRUE
+ converters:
+ test_value: '\s+'
+ requirements:
+ _access: 'TRUE'
diff --git a/core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php
new file mode 100644
index 00000000000..a1438a0108e
--- /dev/null
+++ b/core/modules/system/tests/modules/session_test/src/Controller/LegacySessionTestController.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\session_test\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+
+/**
+ * Controller providing page callbacks for legacy session tests.
+ */
+class LegacySessionTestController extends ControllerBase {
+
+ /**
+ * Prints the stored session value to the screen.
+ */
+ public function get(): array {
+ return empty($_SESSION['legacy_test_value'])
+ ? []
+ : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $_SESSION['legacy_test_value']])];
+ }
+
+ /**
+ * Stores a value in $_SESSION['legacy_test_value'].
+ *
+ * @param string $test_value
+ * A session value.
+ */
+ public function set(string $test_value): array {
+ $_SESSION['legacy_test_value'] = $test_value;
+
+ return ['#markup' => $this->t('The current value of the stored session variable has been set to %val', ['%val' => $test_value])];
+ }
+
+}
diff --git a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
index 9c7bb97e24b..461581abaa7 100644
--- a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
+++ b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
@@ -11,20 +11,21 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
- * Controller providing page callbacks for the action admin interface.
+ * Controller providing page callbacks for session tests.
*/
class SessionTestController extends ControllerBase {
/**
* Prints the stored session value to the screen.
*
- * @return string
- * A notification message.
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The incoming request.
*/
- public function get() {
- return empty($_SESSION['session_test_value'])
+ public function get(Request $request): array {
+ $value = $request->getSession()->get('session_test_value');
+ return empty($value)
? []
- : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $_SESSION['session_test_value']])];
+ : ['#markup' => $this->t('The current value of the stored session variable is: %val', ['%val' => $value])];
}
/**
@@ -32,11 +33,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
- *
- * @return string
- * A notification message.
*/
- public function getFromSessionObject(Request $request) {
+ public function getFromSessionObject(Request $request): array {
$value = $request->getSession()->get("session_test_key");
return empty($value)
? []
@@ -48,16 +46,13 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
- *
- * @return string
- * A notification message with session ID.
*/
- public function getId(Request $request) {
- // Set a value in $_SESSION, so that SessionManager::save() will start
+ public function getId(Request $request): array {
+ // Set a value in session, so that SessionManager::save() will start
// a session.
- $_SESSION['test'] = 'test';
-
- $request->getSession()->save();
+ $session = $request->getSession();
+ $session->set('test', 'test');
+ $session->save();
return ['#markup' => 'session_id:' . session_id() . "\n"];
}
@@ -67,11 +62,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return string
- * A notification message with session ID.
*/
- public function getIdFromCookie(Request $request) {
+ public function getIdFromCookie(Request $request): array {
return [
'#markup' => 'session_id:' . $request->cookies->get(session_name()) . "\n",
'#cache' => ['contexts' => ['cookies:' . session_name()]],
@@ -79,16 +71,15 @@ class SessionTestController extends ControllerBase {
}
/**
- * Stores a value in $_SESSION['session_test_value'].
+ * Stores a value in 'session_test_value' session attribute.
*
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The request object.
* @param string $test_value
* A session value.
- *
- * @return string
- * A notification message.
*/
- public function set($test_value) {
- $_SESSION['session_test_value'] = $test_value;
+ public function set(Request $request, $test_value): array {
+ $request->getSession()->set('session_test_value', $test_value);
return ['#markup' => $this->t('The current value of the stored session variable has been set to %val', ['%val' => $test_value])];
}
@@ -96,25 +87,21 @@ class SessionTestController extends ControllerBase {
/**
* Turns off session saving and then tries to save a value anyway.
*
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The request object.
* @param string $test_value
* A session value.
- *
- * @return string
- * A notification message.
*/
- public function noSet($test_value) {
+ public function noSet(Request $request, $test_value): array {
\Drupal::service('session_handler.write_safe')->setSessionWritable(FALSE);
- $this->set($test_value);
+ $this->set($request, $test_value);
return ['#markup' => $this->t('session saving was disabled, and then %val was set', ['%val' => $test_value])];
}
/**
* Sets a message to me displayed on the following page.
- *
- * @return string
- * A notification message.
*/
- public function setMessage() {
+ public function setMessage(): Response {
$this->messenger()->addStatus($this->t('This is a dummy message.'));
return new Response((string) $this->t('A message was set.'));
// Do not return anything, so the current request does not result in a
@@ -124,11 +111,8 @@ class SessionTestController extends ControllerBase {
/**
* Sets a message but call drupal_save_session(FALSE).
- *
- * @return string
- * A notification message.
*/
- public function setMessageButDoNotSave() {
+ public function setMessageButDoNotSave(): array {
\Drupal::service('session_handler.write_safe')->setSessionWritable(FALSE);
$this->setMessage();
return ['#markup' => ''];
@@ -136,11 +120,8 @@ class SessionTestController extends ControllerBase {
/**
* Only available if current user is logged in.
- *
- * @return string
- * A notification message.
*/
- public function isLoggedIn() {
+ public function isLoggedIn(): array {
return ['#markup' => $this->t('User is logged in.')];
}
@@ -149,20 +130,13 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * The response.
*/
- public function traceHandler(Request $request) {
- // Start a session if necessary, set a value and then save and close it.
- $request->getSession()->start();
- if (empty($_SESSION['trace-handler'])) {
- $_SESSION['trace-handler'] = 1;
- }
- else {
- $_SESSION['trace-handler']++;
- }
- $request->getSession()->save();
+ public function traceHandler(Request $request): Response {
+ // Increment trace-handler counter and save the session.
+ $session = $request->getSession();
+ $counter = $session->get('trace-handler', 0);
+ $session->set('trace-handler', $counter + 1);
+ $session->save();
// Collect traces and return them in JSON format.
$trace = \Drupal::service('session_test.session_handler_proxy_trace')->getArrayCopy();
@@ -182,15 +156,13 @@ class SessionTestController extends ControllerBase {
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request.
*
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * The response.
- *
* @throws \AssertionError
*/
- public function traceHandlerRewriteUnmodified(Request $request) {
+ public function traceHandlerRewriteUnmodified(Request $request): Response {
// Assert that there is an existing session with stacked handler trace data.
+ $session = $request->getSession();
assert(
- is_int($_SESSION['trace-handler']) && $_SESSION['trace-handler'] > 0,
+ is_int($session->get('trace-handler')) && $session->get('trace-handler') > 0,
'Existing stacked session handler trace not found'
);
@@ -199,7 +171,7 @@ class SessionTestController extends ControllerBase {
ini_get('session.lazy_write'),
'session.lazy_write must be enabled to invoke updateTimestamp()'
);
- $request->getSession()->save();
+ $session->save();
// Collect traces and return them in JSON format.
$trace = \Drupal::service('session_test.session_handler_proxy_trace')->getArrayCopy();
@@ -212,11 +184,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * A response object containing the session values and the user ID.
*/
- public function getSession(Request $request) {
+ public function getSession(Request $request): Response {
return new JsonResponse(['session' => $request->getSession()->all(), 'user' => $this->currentUser()->id()]);
}
@@ -227,11 +196,8 @@ class SessionTestController extends ControllerBase {
* The request object.
* @param string $test_value
* A value to set on the session.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * A response object containing the session values and the user ID.
*/
- public function setSession(Request $request, $test_value) {
+ public function setSession(Request $request, $test_value): Response {
$session = $request->getSession();
$session->set('test_value', $test_value);
return new JsonResponse(['session' => $session->all(), 'user' => $this->currentUser()->id()]);
@@ -242,11 +208,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- * The response object.
*/
- public function setSessionBagFlag(Request $request) {
+ public function setSessionBagFlag(Request $request): Response {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
$bag->setFlag();
@@ -258,11 +221,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- * The response object.
*/
- public function clearSessionBagFlag(Request $request) {
+ public function clearSessionBagFlag(Request $request): Response {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
$bag->clearFlag();
@@ -274,11 +234,8 @@ class SessionTestController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
- *
- * @return \Symfony\Component\HttpFoundation\Response
- * The response object.
*/
- public function hasSessionBagFlag(Request $request) {
+ public function hasSessionBagFlag(Request $request): Response {
/** @var \Drupal\session_test\Session\TestSessionBag */
$bag = $request->getSession()->getBag(TestSessionBag::BAG_NAME);
return new Response(empty($bag->hasFlag())
@@ -293,7 +250,7 @@ class SessionTestController extends ControllerBase {
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*/
- public function triggerWriteException(Request $request) {
+ public function triggerWriteException(Request $request): Response {
$session = $request->getSession();
$session->set('test_value', 'Ensure session contains some data');
diff --git a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
index fc48756de51..7bfc10ef0ef 100644
--- a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
+++ b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Drupal\theme_test\Hook;
-use Drupal\Core\Hook\Attribute\Preprocess;
+use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for theme_test.
@@ -14,7 +14,7 @@ class ThemeTestThemeHooks {
/**
* Implements hook_preprocess_HOOK().
*/
- #[Preprocess('theme_test_preprocess_suggestions__monkey')]
+ #[Hook('preprocess_theme_test_preprocess_suggestions__monkey')]
public function preprocessTestSuggestions(&$variables): void {
$variables['foo'] = 'Monkey';
}
diff --git a/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php b/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
index 272ad65eff3..f5d0c150118 100644
--- a/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
+++ b/core/modules/system/tests/modules/twig_loader_test/src/Loader/TestLoader.php
@@ -24,7 +24,7 @@ class TestLoader implements LoaderInterface {
/**
* {@inheritdoc}
*/
- public function exists(string $name) {
+ public function exists(string $name): bool {
return TRUE;
}
diff --git a/core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php b/core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php
new file mode 100644
index 00000000000..5927e31e460
--- /dev/null
+++ b/core/modules/system/tests/modules/update_script_test/src/Hook/UpdateScriptTestRequirements.php
@@ -0,0 +1,59 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\update_script_test\Hook;
+
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Requirements for the Update Script Test module.
+ */
+class UpdateScriptTestRequirements {
+
+ public function __construct(
+ protected readonly ConfigFactoryInterface $configFactory,
+ ) {}
+
+ /**
+ * Implements hook_update_requirements().
+ */
+ #[Hook('update_requirements')]
+ public function update(): array {
+ $requirements = [];
+ // Set a requirements warning or error when the test requests it.
+ $requirement_type = $this->configFactory->get('update_script_test.settings')->get('requirement_type');
+ switch ($requirement_type) {
+ case REQUIREMENT_WARNING:
+ $requirements['update_script_test'] = [
+ 'title' => 'Update script test',
+ 'value' => 'Warning',
+ 'description' => 'This is a requirements warning provided by the update_script_test module.',
+ 'severity' => REQUIREMENT_WARNING,
+ ];
+ break;
+
+ case REQUIREMENT_ERROR:
+ $requirements['update_script_test'] = [
+ 'title' => 'Update script test',
+ 'value' => 'Error',
+ 'description' => 'This is a (buggy description fixed in update_script_test_requirements_alter()) requirements error provided by the update_script_test module.',
+ 'severity' => REQUIREMENT_ERROR,
+ ];
+ break;
+ }
+ return $requirements;
+ }
+
+ /**
+ * Implements hook_update_requirements_alter().
+ */
+ #[Hook('update_requirements_alter')]
+ public function updateAlter(array &$requirements): void {
+ if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === REQUIREMENT_ERROR) {
+ $requirements['update_script_test']['description'] = 'This is a requirements error provided by the update_script_test module.';
+ }
+ }
+
+}
diff --git a/core/modules/system/tests/modules/update_script_test/update_script_test.install b/core/modules/system/tests/modules/update_script_test/update_script_test.install
index 5a641fd9564..c380aabd7ff 100644
--- a/core/modules/system/tests/modules/update_script_test/update_script_test.install
+++ b/core/modules/system/tests/modules/update_script_test/update_script_test.install
@@ -8,48 +8,6 @@
declare(strict_types=1);
/**
- * Implements hook_requirements().
- */
-function update_script_test_requirements($phase): array {
- $requirements = [];
-
- if ($phase == 'update') {
- // Set a requirements warning or error when the test requests it.
- $requirement_type = \Drupal::config('update_script_test.settings')->get('requirement_type');
- switch ($requirement_type) {
- case REQUIREMENT_WARNING:
- $requirements['update_script_test'] = [
- 'title' => 'Update script test',
- 'value' => 'Warning',
- 'description' => 'This is a requirements warning provided by the update_script_test module.',
- 'severity' => REQUIREMENT_WARNING,
- ];
- break;
-
- case REQUIREMENT_ERROR:
- $requirements['update_script_test'] = [
- 'title' => 'Update script test',
- 'value' => 'Error',
- 'description' => 'This is a (buggy description fixed in update_script_test_requirements_alter()) requirements error provided by the update_script_test module.',
- 'severity' => REQUIREMENT_ERROR,
- ];
- break;
- }
- }
-
- return $requirements;
-}
-
-/**
- * Implements hook_requirements_alter().
- */
-function update_script_test_requirements_alter(array &$requirements): void {
- if (isset($requirements['update_script_test']) && $requirements['update_script_test']['severity'] === REQUIREMENT_ERROR) {
- $requirements['update_script_test']['description'] = 'This is a requirements error provided by the update_script_test module.';
- }
-}
-
-/**
* Implements hook_update_last_removed().
*/
function update_script_test_update_last_removed(): int {
diff --git a/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php b/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php
new file mode 100644
index 00000000000..de96ce3e36a
--- /dev/null
+++ b/core/modules/system/tests/modules/update_test_schema/src/Hook/UpdateTestSchemaRequirements.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\update_test_schema\Hook;
+
+use Drupal\Component\Render\FormattableMarkup;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\Url;
+
+/**
+ * Requirements for the Update Test Schema module.
+ */
+class UpdateTestSchemaRequirements {
+
+ /**
+ * Implements hook_runtime_requirements().
+ */
+ #[Hook('runtime_requirements')]
+ public function runtime(): array {
+ $requirements = [];
+ $requirements['path_alias_test'] = [
+ 'title' => 'Path alias test',
+ 'value' => 'Check a path alias for the admin page',
+ 'severity' => REQUIREMENT_INFO,
+ 'description' => new FormattableMarkup('Visit <a href=":link">the structure page</a> to do many useful things.', [
+ ':link' => Url::fromRoute('system.admin_structure')->toString(),
+ ]),
+ ];
+ return $requirements;
+ }
+
+}
diff --git a/core/modules/system/tests/modules/update_test_schema/update_test_schema.install b/core/modules/system/tests/modules/update_test_schema/update_test_schema.install
index 305d2cc7913..0ad88c618bd 100644
--- a/core/modules/system/tests/modules/update_test_schema/update_test_schema.install
+++ b/core/modules/system/tests/modules/update_test_schema/update_test_schema.install
@@ -12,25 +12,6 @@ use Drupal\Core\Url;
use Drupal\Component\Render\FormattableMarkup;
/**
- * Implements hook_requirements().
- */
-function update_test_schema_requirements($phase): array {
- $requirements = [];
- if ($phase === 'runtime') {
- $requirements['path_alias_test'] = [
- 'title' => 'Path alias test',
- 'value' => 'Check a path alias for the admin page',
- 'severity' => REQUIREMENT_INFO,
- 'description' => new FormattableMarkup('Visit <a href=":link">the structure page</a> to do many useful things.', [
- ':link' => Url::fromRoute('system.admin_structure')->toString(),
- ]),
- ];
- }
-
- return $requirements;
-}
-
-/**
* Implements hook_schema().
*
* The schema defined here will vary on state to allow for update hook testing.
diff --git a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
index 42605c114ff..dcf46af35c9 100644
--- a/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
+++ b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
@@ -50,9 +50,11 @@ class TestFileTransfer extends FileTransfer {
* Establishes a mock connection for file transfer.
*/
public function connect() {
+ // @phpstan-ignore property.deprecatedClass
$this->connection = new MockTestConnection();
// Access the connection via the property. The property used to be set via a
// magic method and this can cause problems if coded incorrectly.
+ // @phpstan-ignore property.deprecatedClass
$this->connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@$this->host:$this->port/";
}
@@ -60,6 +62,7 @@ class TestFileTransfer extends FileTransfer {
* Copies a file within the jailed environment.
*/
public function copyFileJailed($source, $destination) {
+ // @phpstan-ignore property.deprecatedClass
$this->connection->run("copyFile $source $destination");
}
@@ -67,6 +70,7 @@ class TestFileTransfer extends FileTransfer {
* Removes a directory within the jailed environment.
*/
protected function removeDirectoryJailed($directory) {
+ // @phpstan-ignore property.deprecatedClass
$this->connection->run("rmdir $directory");
}
@@ -74,6 +78,7 @@ class TestFileTransfer extends FileTransfer {
* Creates a directory within the jailed environment.
*/
public function createDirectoryJailed($directory) {
+ // @phpstan-ignore property.deprecatedClass
$this->connection->run("mkdir $directory");
}
@@ -81,6 +86,7 @@ class TestFileTransfer extends FileTransfer {
* Removes a file within the jailed environment.
*/
public function removeFileJailed($destination) {
+ // @phpstan-ignore property.deprecatedClass
$this->connection->run("rm $destination");
}
diff --git a/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php b/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php
index 4b2779ead48..63e325c5111 100644
--- a/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php
+++ b/core/modules/system/tests/src/Functional/Render/PlaceholderMessageTest.php
@@ -17,7 +17,10 @@ class PlaceholderMessageTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- protected static $modules = ['render_placeholder_message_test'];
+ protected static $modules = [
+ 'render_placeholder_message_test',
+ 'big_pipe_messages_test',
+ ];
/**
* {@inheritdoc}
diff --git a/core/modules/system/tests/src/Functional/Session/LegacySessionTest.php b/core/modules/system/tests/src/Functional/Session/LegacySessionTest.php
new file mode 100644
index 00000000000..84ab1ed9d5b
--- /dev/null
+++ b/core/modules/system/tests/src/Functional/Session/LegacySessionTest.php
@@ -0,0 +1,44 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\Tests\system\Functional\Session;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Drupal legacy session handling tests.
+ *
+ * @group legacy
+ * @group Session
+ */
+class LegacySessionTest extends BrowserTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ protected static $modules = ['session_test'];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected $defaultTheme = 'stark';
+
+ /**
+ * Tests data persistence via the session_test module callbacks.
+ */
+ public function testLegacyDataPersistence(): void {
+ $this->expectDeprecation('Storing values directly in $_SESSION is deprecated in drupal:11.2.0 and will become unsupported in drupal:12.0.0. Use $request-&gt;getSession()-&gt;set() instead. Affected keys: legacy_test_value. See https://www.drupal.org/node/3518527');
+ $value = $this->randomMachineName();
+
+ // Verify that the session value is stored.
+ $this->drupalGet('session-test/legacy-set/' . $value);
+ $this->assertSession()->pageTextContains($value);
+
+ // Verify that the session correctly returned the stored data for an
+ // authenticated user.
+ $this->drupalGet('session-test/legacy-get');
+ $this->assertSession()->pageTextContains($value);
+ }
+
+}
diff --git a/core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php b/core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php
new file mode 100644
index 00000000000..c2bd82782b0
--- /dev/null
+++ b/core/modules/system/tests/src/Kernel/Block/StubPathMatcher.php
@@ -0,0 +1,21 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\Tests\system\Kernel\Block;
+
+use Drupal\Core\Path\PathMatcher;
+
+/**
+ * A class extending PatchMatcher for testing purposes.
+ */
+class StubPathMatcher extends PathMatcher {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFrontPage(): bool {
+ return FALSE;
+ }
+
+}
diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
index e2ceead3475..6d4ff90d5f4 100644
--- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
+++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
@@ -341,6 +341,13 @@ class SystemMenuBlockTest extends KernelTestBase {
* @dataProvider configExpandedTestCases
*/
public function testConfigExpanded($active_route, $menu_block_level, $expected_items): void {
+ // Replace the path.matcher service so it always returns FALSE when
+ // checking whether a route is the front page. Otherwise, the default
+ // service throws an exception when checking routes because all of these
+ // are mocked.
+ $service_definition = $this->container->getDefinition('path.matcher');
+ $service_definition->setClass(StubPathMatcher::class);
+
$block = $this->blockManager->createInstance('system_menu_block:' . $this->menu->id(), [
'region' => 'footer',
'id' => 'machine_name',