From 971747f197ac3fe43d7beb5180d8f25b15040583 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Fri, 1 Mar 2024 15:00:17 +0000 Subject: [PATCH] Issue #3424920 by mondrake: Change core modules test data providers to static, simple cases --- .../tests/src/Kernel/CKEditor5PluginManagerTest.php | 2 +- core/modules/layout_builder/tests/src/Unit/SectionTest.php | 4 ++-- .../media/tests/src/Functional/MediaTypeCreationTest.php | 5 +++-- .../tests/src/Kernel/process/SubProcessWithSkipTest.php | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php index 66a78c4f7cd5..07a5b1bd7eb8 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php @@ -1594,7 +1594,7 @@ public function testDerivedPluginDefinitions(string $yaml, ?string $expected_mes * @return \Generator * Test scenarios. */ - public function providerTestDerivedPluginDefinitions(): \Generator { + public static function providerTestDerivedPluginDefinitions(): \Generator { // Defaults inherited from CKEditor5AspectsOfCKEditor5Plugin. $ckeditor5_aspects_defaults = get_class_vars(CKEditor5AspectsOfCKEditor5Plugin::class); // Defaults inherited from DrupalAspectsOfCKEditor5Plugin. diff --git a/core/modules/layout_builder/tests/src/Unit/SectionTest.php b/core/modules/layout_builder/tests/src/Unit/SectionTest.php index 6ffa19570bdb..c4813f26f042 100644 --- a/core/modules/layout_builder/tests/src/Unit/SectionTest.php +++ b/core/modules/layout_builder/tests/src/Unit/SectionTest.php @@ -231,7 +231,7 @@ public static function providerTestGetThirdPartySettings() { * @covers ::getThirdPartySetting * @dataProvider providerTestGetThirdPartySetting */ - public function testGetThirdPartySetting($provider, $key, $expected, $default = FALSE) { + public function testGetThirdPartySetting(string $provider, string $key, ?string $expected, mixed $default = FALSE): void { if ($default) { $this->assertSame($expected, $this->section->getThirdPartySetting($provider, $key, $default)); } @@ -243,7 +243,7 @@ public function testGetThirdPartySetting($provider, $key, $expected, $default = /** * Provides test data for ::testGetThirdPartySetting(). */ - public function providerTestGetThirdPartySetting() { + public static function providerTestGetThirdPartySetting(): array { $data = []; $data[] = [ 'bad_judgement', diff --git a/core/modules/media/tests/src/Functional/MediaTypeCreationTest.php b/core/modules/media/tests/src/Functional/MediaTypeCreationTest.php index c9162e07caef..ed68216a57fe 100644 --- a/core/modules/media/tests/src/Functional/MediaTypeCreationTest.php +++ b/core/modules/media/tests/src/Functional/MediaTypeCreationTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\media\Functional; use Drupal\media\Entity\MediaType; +use Drupal\TestTools\Random; /** * Ensures that media UI works correctly without JavaScript. @@ -49,8 +50,8 @@ public function testMediaTypeCreationForm($button_label, $address, $machine_name /** * Data provider for testMediaTypeCreationForm(). */ - public function providerMediaTypeCreationForm() { - $machine_name = $this->randomMachineName(); + public static function providerMediaTypeCreationForm() { + $machine_name = Random::machineName(); return [ [ 'Save', diff --git a/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php b/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php index ad89fceeebf3..308d21a902fb 100644 --- a/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/SubProcessWithSkipTest.php @@ -109,7 +109,7 @@ public function testSubProcessSkip(string $method, array $expected_data): void { * * @return array */ - public function providerTestSubProcessSkip(): array { + public static function providerTestSubProcessSkip(): array { return [ 'skip row' => [ 'method' => 'row', -- GitLab