From 3035e99a9e4006a94881ad8efa151f8bed9d92bb Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 20 Sep 2024 09:50:07 +0200 Subject: [PATCH] Mutate remaining data providers to static ones --- .../Tests/Formatter/OutputFormatterTest.php | 2 +- .../Factory/CachingFactoryDecoratorTest.php | 4 +-- .../Component/Intl/Tests/LocalesTest.php | 6 ++--- .../Intl/Tests/ResourceBundleTestCase.php | 26 +++++++------------ .../Tests/Transport/ConnectionTest.php | 2 +- .../AbstractObjectNormalizerTest.php | 2 +- .../String/Tests/AbstractUnicodeTestCase.php | 2 +- 7 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 21905f4750dd0..f65e0a15df158 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -200,7 +200,7 @@ public static function provideInlineStyleOptionsCases() ]; } - public function provideInlineStyleTagsWithUnknownOptions() + public static function provideInlineStyleTagsWithUnknownOptions() { return [ ['', 'abc'], diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index 893af48593ebf..cdad28b5d17bc 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -586,7 +586,7 @@ public static function provideDistinguishedChoices() ]; } - public function provideSameKeyChoices() + public static function provideSameKeyChoices() { // Only test types here that can be used as array keys return [ @@ -597,7 +597,7 @@ public function provideSameKeyChoices() ]; } - public function provideDistinguishedKeyChoices() + public static function provideDistinguishedKeyChoices() { // Only test types here that can be used as array keys return [ diff --git a/src/Symfony/Component/Intl/Tests/LocalesTest.php b/src/Symfony/Component/Intl/Tests/LocalesTest.php index 5e3279622bfb2..4e331d2854601 100644 --- a/src/Symfony/Component/Intl/Tests/LocalesTest.php +++ b/src/Symfony/Component/Intl/Tests/LocalesTest.php @@ -21,12 +21,12 @@ class LocalesTest extends ResourceBundleTestCase { public function testGetLocales() { - $this->assertSame($this->getLocales(), Locales::getLocales()); + $this->assertSame(static::getLocales(), Locales::getLocales()); } public function testGetAliases() { - $this->assertSame($this->getLocaleAliases(), Locales::getAliases()); + $this->assertSame(static::getLocaleAliases(), Locales::getAliases()); } /** @@ -41,7 +41,7 @@ public function testGetNames($displayLocale) // We can't assert on exact list of locale, as there's too many variations. // The best we can do is to make sure getNames() returns a subset of what getLocales() returns. $this->assertNotEmpty($locales); - $this->assertEmpty(array_diff($locales, $this->getLocales())); + $this->assertEmpty(array_diff($locales, static::getLocales())); } public function testGetNamesDefaultLocale() diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php b/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php index fda9eda6c4bf4..5b7ee8f932ff0 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php @@ -758,45 +758,37 @@ protected function tearDown(): void \Locale::setDefault($this->defaultLocale); } - public function provideLocales() + public static function provideLocales() { return array_map( function ($locale) { return [$locale]; }, - $this->getLocales() + static::getLocales() ); } - public function provideLocaleAliases() + public static function provideLocaleAliases() { return array_map( function ($alias, $ofLocale) { return [$alias, $ofLocale]; }, - array_keys($this->getLocaleAliases()), - $this->getLocaleAliases() + array_keys(static::getLocaleAliases()), + static::getLocaleAliases() ); } - public function provideRootLocales() - { - return array_map( - function ($locale) { return [$locale]; }, - $this->getRootLocales() - ); - } - - protected function getLocales() + protected static function getLocales() { return self::LOCALES; } - protected function getLocaleAliases() + protected static function getLocaleAliases() { return self::LOCALE_ALIASES; } - protected function getRootLocales() + protected static function getRootLocales() { if (null === self::$rootLocales) { - self::$rootLocales = array_filter($this->getLocales(), function ($locale) { + self::$rootLocales = array_filter(static::getLocales(), function ($locale) { // no locales for which fallback is possible (e.g "en_GB") return !str_contains($locale, '_'); }); diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php index 51f6963a318b3..c238c77a8b620 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php @@ -500,7 +500,7 @@ public function testFindAllSqlGenerated(AbstractPlatform $platform, string $expe $connection->findAll(50); } - public function provideFindAllSqlGeneratedByPlatform(): iterable + public static function provideFindAllSqlGeneratedByPlatform(): iterable { yield 'MySQL' => [ class_exists(MySQLPlatform::class) ? new MySQLPlatform() : new MySQL57Platform(), diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index b700f6ee713f6..e413be0c1891d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -701,7 +701,7 @@ public function testDenormalizeBooleanTypesWithNotMatchingData(array $data, stri $normalizer->denormalize($data, $type); } - public function provideBooleanTypesData() + public static function provideBooleanTypesData() { return [ [['foo' => true], FalsePropertyDummy::class], diff --git a/src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php b/src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php index cddfe866c89b1..4bb4e9356bc07 100644 --- a/src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php +++ b/src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php @@ -52,7 +52,7 @@ public function testAsciiClosureRule() $this->assertSame('Dieser Wert sollte grOEsser oder gleich', (string) $s->ascii([$rule])); } - public function provideCreateFromCodePoint(): array + public static function provideCreateFromCodePoint(): array { return [ ['', []],