diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php index 6741ab1294e0a834256bf69cdd86cf98f3f0a560..68f29bb8de686e59eab38e7f9ab56776c56a7716 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php @@ -166,7 +166,7 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_ */ public function getBlockTests() { $blocks = []; - foreach ($this->getTestThemes() as $theme) { + foreach (static::getTestThemes() as $theme) { $blocks += [ "$theme: block-powered" => [ 'theme' => $theme, @@ -233,7 +233,7 @@ public function getBlockTests() { */ public function testEditModeEnableDisable() { $this->markTestSkipped("Skipped due to frequent random test failures. See https://www.drupal.org/project/drupal/issues/3317520"); - foreach ($this->getTestThemes() as $theme) { + foreach (static::getTestThemes() as $theme) { $this->enableTheme($theme); $block = $this->placeBlock('system_powered_by_block'); foreach (['contextual_link', 'toolbar_link'] as $enable_option) { @@ -270,7 +270,7 @@ public function testEditModeEnableDisable() { public function testValidationMessages() { $page = $this->getSession()->getPage(); $web_assert = $this->assertSession(); - foreach ($this->getTestThemes() as $theme) { + foreach (static::getTestThemes() as $theme) { $this->enableTheme($theme); $block = $this->placeBlock('settings_tray_test_validation'); $this->drupalGet('user'); diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php index 8bd960e9f3e50fdfb00270ae58dd047d201d7720..ae13a0fdf399c09db09ea88833aa01cb025f7451 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php @@ -156,7 +156,7 @@ protected function assertOffCanvasBlockFormIsValid() { /** * {@inheritdoc} */ - protected function getTestThemes() { + protected static function getTestThemes() { // Remove 'claro' theme. Settings Tray "Edit Mode" will not work with this // theme because it removes all contextual links. return array_filter(parent::getTestThemes(), function ($theme) { diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php index 92c0c134f0cfc323f84acd00225a1ab694b8c898..959b42bea4c556fca0f235b3b302a8ad8198c4d8 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -125,7 +125,7 @@ public function testNarrowWidth() { $web_assert = $this->assertSession(); // Test the same functionality on multiple themes. - foreach ($this->getTestThemes() as $theme) { + foreach (static::getTestThemes() as $theme) { $this->enableTheme($theme); // Testing at the wider width. $this->getSession()->resizeWindow($narrow_width_breakpoint + $offset, $height); diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php index 6d3c900ff3326e3fdc266083b818905e0a82416e..f09aaef10eb410144e46ce945ef7a1472c9bdc20 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php @@ -107,7 +107,7 @@ protected function getOffCanvasDialog() { * @return string[] * Theme names to test. */ - protected function getTestThemes() { + protected static function getTestThemes() { return ['claro', 'olivero', 'stable9', 'stark']; } @@ -130,8 +130,8 @@ protected function assertElementVisibleAfterWait($selector, $locator, $timeout = /** * Data provider that returns theme name as the sole argument. */ - public function themeDataProvider() { - $themes = $this->getTestThemes(); + public static function themeDataProvider() { + $themes = static::getTestThemes(); $data = []; foreach ($themes as $theme) { $data[$theme] = [ diff --git a/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php b/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php index 8996accd87bf6bb9932122025c104ad7204002eb..e2f679d61c30645c8129247940027de5db6fc350 100644 --- a/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php +++ b/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php @@ -89,7 +89,7 @@ public function testSecurityUpdateAvailability($site_patch_version, array $expec * - 8.0.1 Insecure * - 8.0.0 Insecure */ - public function securityUpdateAvailabilityProvider() { + public static function securityUpdateAvailabilityProvider() { $test_cases = [ // Security release available for site minor release 0. // No releases for next minor. diff --git a/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php b/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php index e80dc469060e51665335be4398a40d01ef04b9d4..e56b73c2d120fa50c3fc9f401c4239b57ec6e09a 100644 --- a/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php +++ b/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php @@ -87,7 +87,7 @@ protected function setReleaseMetadata(string $file): void { * @return array[] * Test data. */ - public function providerProjectStatus(): array { + public static function providerProjectStatus(): array { return [ 'revoked' => [ 'fixture' => '/../../fixtures/release-history/drupal.project_status.revoked.0.2.xml', diff --git a/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php b/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php index 6752f91065804878312c93a079a36e3d25f1be81..f5bdf2b8c80107a24c063fb3a1e1f185be229bce 100644 --- a/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php @@ -44,7 +44,7 @@ public function testAcceptExposedInput($options, $value, $expected): void { * @return array[] * The test cases. */ - public function provideAcceptExposedInput(): array { + public static function provideAcceptExposedInput(): array { // [$options, $value, $expected] return [ // Not exposed by default. Bypass parsing and return true. diff --git a/core/tests/Drupal/Tests/Core/Render/ElementTest.php b/core/tests/Drupal/Tests/Core/Render/ElementTest.php index eba2dd726845e4058f98ee7eef641990da38fa10..709793dff076d20c94e06178982da48b895609be 100644 --- a/core/tests/Drupal/Tests/Core/Render/ElementTest.php +++ b/core/tests/Drupal/Tests/Core/Render/ElementTest.php @@ -236,7 +236,7 @@ public function testIsRenderArray($build, $expected) { ); } - public function dataProviderIsRenderArray() { + public static function dataProviderIsRenderArray() { return [ 'valid markup render array' => [['#markup' => 'hello world'], TRUE], 'invalid "foo" string' => [['foo', '#markup' => 'hello world'], FALSE], diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 9ee5ba13c50efd64c674eedbd3ea9b019b632413..552fbee231d63f866d63b340910e34237c66dffb 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -44,7 +44,7 @@ class RendererTest extends RendererTestBase { public function testRenderBasic($build, $expected, callable $setup_code = NULL) { if (isset($setup_code)) { $setup_code = $setup_code->bindTo($this); - $setup_code(); + $setup_code($this->themeManager); } if (isset($build['#markup'])) { @@ -63,7 +63,7 @@ public function testRenderBasic($build, $expected, callable $setup_code = NULL) * * @return array */ - public function providerTestRenderBasic() { + public static function providerTestRenderBasic() { $data = []; // Part 1: the most simplistic render arrays possible, none using #theme. @@ -266,10 +266,10 @@ function ($elements) { '#theme_wrappers' => ['container'], '#attributes' => ['class' => ['baz']], ]; - $setup_code_type_link = function () { - $this->themeManager->expects($this->exactly(2)) + $setup_code_type_link = function ($themeManager) { + $themeManager->expects(static::exactly(2)) ->method('render') - ->with($this->logicalOr('common_test_foo', 'container')) + ->with(static::logicalOr('common_test_foo', 'container')) ->willReturnCallback(function ($theme, $vars) { if ($theme == 'container') { return '<div' . (string) (new Attribute($vars['#attributes'])) . '>' . $vars['#children'] . "</div>\n"; @@ -293,10 +293,10 @@ function ($elements) { '#url' => 'https://www.drupal.org', '#title' => 'bar', ]; - $setup_code_type_link = function () { - $this->themeManager->expects($this->exactly(2)) + $setup_code_type_link = function ($themeManager) { + $themeManager->expects(static::exactly(2)) ->method('render') - ->with($this->logicalOr('link', 'container')) + ->with(static::logicalOr('link', 'container')) ->willReturnCallback(function ($theme, $vars) { if ($theme == 'container') { return '<div' . (string) (new Attribute($vars['#attributes'])) . '>' . $vars['#children'] . "</div>\n"; @@ -332,8 +332,8 @@ function ($elements) { 'container', ], ]; - $setup_code = function () { - $this->themeManager->expects($this->exactly(2)) + $setup_code = function ($themeManager) { + $themeManager->expects(static::exactly(2)) ->method('render') ->with('container') ->willReturnCallback(function ($theme, $vars) { @@ -347,8 +347,8 @@ function ($elements) { '#theme_wrappers' => [['container']], '#attributes' => ['class' => ['foo']], ]; - $setup_code = function () { - $this->themeManager->expects($this->once()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::once()) ->method('render') ->with(['container']) ->willReturnCallback(function ($theme, $vars) { @@ -364,10 +364,10 @@ function ($elements) { '#theme' => ['suggestion_not_implemented'], '#markup' => 'foo', ]; - $setup_code = function () { - $this->themeManager->expects($this->once()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::once()) ->method('render') - ->with(['suggestion_not_implemented'], $this->anything()) + ->with(['suggestion_not_implemented'], static::anything()) ->willReturn(FALSE); }; $data[] = [$build, 'foo', $setup_code]; @@ -379,10 +379,10 @@ function ($elements) { '#markup' => 'foo', ], ]; - $setup_code = function () { - $this->themeManager->expects($this->once()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::once()) ->method('render') - ->with(['suggestion_not_implemented'], $this->anything()) + ->with(['suggestion_not_implemented'], static::anything()) ->willReturn(FALSE); }; $data[] = [$build, 'foo', $setup_code]; @@ -392,11 +392,11 @@ function ($elements) { '#theme' => ['common_test_empty'], '#markup' => 'foo', ]; - $theme_function_output = $this->randomContextValue(); - $setup_code = function () use ($theme_function_output) { - $this->themeManager->expects($this->once()) + $theme_function_output = static::randomContextValue(); + $setup_code = function ($themeManager) use ($theme_function_output) { + $themeManager->expects(static::once()) ->method('render') - ->with(['common_test_empty'], $this->anything()) + ->with(['common_test_empty'], static::anything()) ->willReturn($theme_function_output); }; $data[] = [$build, $theme_function_output, $setup_code]; @@ -420,10 +420,10 @@ function ($elements) { '#children' => 'baz', 'child' => ['#markup' => 'boo'], ]; - $setup_code = function () { - $this->themeManager->expects($this->once()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::once()) ->method('render') - ->with('common_test_foo', $this->anything()) + ->with('common_test_foo', static::anything()) ->willReturn('foobar'); }; $data[] = [$build, 'foobar', $setup_code]; @@ -439,8 +439,8 @@ function ($elements) { '#markup' => 'boo', ], ]; - $setup_code = function () { - $this->themeManager->expects($this->never()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::never()) ->method('render'); }; $data[] = [$build, 'boo', $setup_code]; @@ -455,8 +455,8 @@ function ($elements) { '#markup' => 'boo', ], ]; - $setup_code = function () { - $this->themeManager->expects($this->never()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::never()) ->method('render'); }; $data[] = [$build, 'baz', $setup_code]; @@ -474,8 +474,8 @@ function ($elements) { '#markup' => 'kitten', ], ]; - $setup_code = function () { - $this->themeManager->expects($this->never()) + $setup_code = function ($themeManager) { + $themeManager->expects(static::never()) ->method('render'); }; $data[] = [$build, 'kitten', $setup_code]; diff --git a/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php b/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php index 13b7feec432da3cdbb948ada7d3e6166bb52a09d..9abc270c75c19d3c507f84e98b362c652c67f68e 100644 --- a/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php +++ b/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php @@ -86,7 +86,7 @@ public function testCalculatePermissions(int $uid, bool $expect_admin_rights): v * @return array * A list of test scenarios. */ - public function calculatePermissionsProvider(): array { + public static function calculatePermissionsProvider(): array { $cases['is-super-user'] = [1, TRUE]; $cases['is-normal-user'] = [2, FALSE]; return $cases; @@ -122,7 +122,7 @@ public function testAlterPermissions(int $uid): void { * @return array * A list of test scenarios. */ - public function alterPermissionsProvider(): array { + public static function alterPermissionsProvider(): array { $cases['is-super-user'] = [1]; $cases['is-normal-user'] = [2]; return $cases; diff --git a/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php b/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php index a7fc00db10ea13145b5a9e5162d6624f4d2ea58b..36e141a410b2bc3cb354ac0adbaaeaacbb3d3dd8 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php @@ -124,7 +124,7 @@ public function testCalculatePermissions(array $roles, bool $expect_admin_rights * @return array * A list of test scenarios. */ - public function calculatePermissionsProvider(): array { + public static function calculatePermissionsProvider(): array { $cases['no-roles'] = [ 'roles' => [], 'expect_admin_rights' => FALSE, diff --git a/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php b/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php index bf6b368907fe95df6cbaf5bfb6e7f2e43ac5ca1a..ef3becb9e12949f49a48a7c703a694f2220aebf1 100644 --- a/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php +++ b/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php @@ -41,7 +41,7 @@ public function testHexToHsl(string $hex, array $expected_hsl): void { * @return array[] * The test data. */ - public function hexCodes(): array { + public static function hexCodes(): array { return [ 'Blue Lagoon' => ['#1b9ae4', [202, 79, 50]], 'Firehouse' => ['#a30f0f', [0, 83, 35]],