From 42ad9bb1d20a0451e1be0766374af27483393482 Mon Sep 17 00:00:00 2001 From: Christian Kuhn Date: Wed, 28 Feb 2024 10:07:25 +0100 Subject: [PATCH] [TASK] Update invalid test data providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of https://review.typo3.org/c/Packages/TYPO3.CMS/+/83155 to TYPO3 v12. PHPUnit 10.5.18 introduces deprecation warning due to use of non-matching parameter names with data providers, introduced by https://github.com/sebastianbergmann/phpunit/pull/5812. This patch backports changes that were made for PHPUnit v11 support, which also addresses these kind of deprecation warnings too. Resolves: #103634 Related: #103222 Releases: 12.4 Change-Id: Ia9a1f7c5d62894dc80b3d1f9b465fb488b3250fc Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83788 Tested-by: Anja Leichsenring Reviewed-by: Anja Leichsenring Reviewed-by: Christian Kuhn Tested-by: core-ci Tested-by: Stefan Bürk Reviewed-by: Stefan Bürk Tested-by: Christian Kuhn --- .../FrontendConfigurationManagerTest.php | 10 +++--- .../ControllerArgumentsMappingTest.php | 21 +++--------- .../Persistence/QueryLocalizedDataTest.php | 32 +++++++++---------- .../Persistence/TranslatedSiteContentTest.php | 6 ++-- .../Validation/Validator/UrlValidatorTest.php | 4 +-- 5 files changed, 30 insertions(+), 43 deletions(-) diff --git a/Tests/Functional/Configuration/FrontendConfigurationManagerTest.php b/Tests/Functional/Configuration/FrontendConfigurationManagerTest.php index f077fce68..2d6882ae0 100644 --- a/Tests/Functional/Configuration/FrontendConfigurationManagerTest.php +++ b/Tests/Functional/Configuration/FrontendConfigurationManagerTest.php @@ -110,7 +110,7 @@ public static function overrideConfigurationFromFlexFormSettingsDataProvider(): ], ], ], - [ + 'expected' => [ 'booleanField' => '1', ], ]; @@ -345,16 +345,16 @@ public static function overrideConfigurationFromFlexFormSettingsDataProvider(): #[DataProvider('overrideConfigurationFromFlexFormSettingsDataProvider')] #[Test] public function overrideConfigurationFromFlexFormIgnoresConfiguredEmptyFlexFormSettings( - string $flexFormConfiguration, - array $frameworkConfiguration, + string $flexForm, + array $typoScript, array $expected ): void { $frontendTypoScript = new FrontendTypoScript(new RootNode(), []); - $frontendTypoScript->setSetupArray($frameworkConfiguration); + $frontendTypoScript->setSetupArray($typoScript); $GLOBALS['TYPO3_REQUEST'] = (new ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript); $contentObject = new ContentObjectRenderer(); - $contentObject->data = ['pi_flexform' => $flexFormConfiguration]; + $contentObject->data = ['pi_flexform' => $flexForm]; $frontendConfigurationManager = $this->get(FrontendConfigurationManager::class); $frontendConfigurationManager->setContentObject($contentObject); $frontendConfigurationManager->setConfiguration(['extensionName' => 'foo', 'pluginName' => 'foo']); diff --git a/Tests/Functional/Mvc/Controller/ControllerArgumentsMappingTest.php b/Tests/Functional/Mvc/Controller/ControllerArgumentsMappingTest.php index fafb209f6..52efdac0f 100644 --- a/Tests/Functional/Mvc/Controller/ControllerArgumentsMappingTest.php +++ b/Tests/Functional/Mvc/Controller/ControllerArgumentsMappingTest.php @@ -19,7 +19,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\LanguageAspect; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; @@ -33,20 +32,8 @@ final class ControllerArgumentsMappingTest extends FunctionalTestCase { - /** - * @var Request - */ - protected $request; - - /** - * @var ResponseInterface - */ - protected $response; - - /** - * @var BlogController - */ - protected $controller; + private Request $request; + private BlogController $controller; protected array $testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example']; @@ -81,12 +68,12 @@ public static function actionGetsBlogFromUidArgumentDataProvider(): array [ 'language' => 0, 'blogUid' => 1, - 'blogTitle' => 'Blog 1', + 'expectedTitle' => 'Blog 1', ], [ 'language' => 1, 'blogUid' => 1, - 'blogTitle' => 'Blog 1 DA', + 'expectedTitle' => 'Blog 1 DA', ], ]; } diff --git a/Tests/Functional/Persistence/QueryLocalizedDataTest.php b/Tests/Functional/Persistence/QueryLocalizedDataTest.php index a550ed56f..8080625a6 100644 --- a/Tests/Functional/Persistence/QueryLocalizedDataTest.php +++ b/Tests/Functional/Persistence/QueryLocalizedDataTest.php @@ -475,17 +475,17 @@ public static function queryFirst5PostsDataProvider(): array ]; return [ [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_MIXED, 'expected' => $lang0Expected, ], [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_OFF, 'expected' => $lang0Expected, ], [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_MIXED, 'expected' => [ [ @@ -594,7 +594,7 @@ public static function queryFirst5PostsDataProvider(): array ], ], 'only fetch records with l10n_parent and try overlays' => [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_ON, // here we have only 4 items instead of 5 as post "Post DA only" uid:15 has no language 0 parent, // so with overlay enabled it's not shown @@ -680,7 +680,7 @@ public static function queryFirst5PostsDataProvider(): array ], ], [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_OFF, 'expected' => [ [ @@ -846,22 +846,22 @@ public static function queryPostsByPropertyDataProvider(): array return [ [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_MIXED, 'expected' => $lang0Expected, ], [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_ON_WITH_FLOATING, 'expected' => $lang0Expected, ], [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_OFF, 'expected' => $lang0Expected, ], [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_MIXED, 'expected' => [ [ @@ -897,7 +897,7 @@ public static function queryPostsByPropertyDataProvider(): array ], ], [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_ON, 'expected' => [ [ @@ -918,7 +918,7 @@ public static function queryPostsByPropertyDataProvider(): array ], ], [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_ON_WITH_FLOATING, 'expected' => [ [ @@ -954,7 +954,7 @@ public static function queryPostsByPropertyDataProvider(): array ], ], [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_OFF, 'expected' => [ [ @@ -1038,17 +1038,17 @@ public static function postsWithoutRespectingSysLanguageDataProvider(): array ]; return [ 'default with overlays' => [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_ON, 'expected' => $allLanguages, ], 'default without overlays, show all languages' => [ - 'language' => 0, + 'languageUid' => 0, 'overlay' => LanguageAspect::OVERLAYS_OFF, 'expected' => $allLanguages, ], 'DA with overlays, shows translated records twice (which is a bug)' => [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_ON, 'expected' => [ [ @@ -1064,7 +1064,7 @@ public static function postsWithoutRespectingSysLanguageDataProvider(): array ], ], 'DA without overlays, queries DA language directly' => [ - 'language' => 1, + 'languageUid' => 1, 'overlay' => LanguageAspect::OVERLAYS_OFF, 'expected' => $allLanguages, ], diff --git a/Tests/Functional/Persistence/TranslatedSiteContentTest.php b/Tests/Functional/Persistence/TranslatedSiteContentTest.php index c434bf39b..9a581d804 100644 --- a/Tests/Functional/Persistence/TranslatedSiteContentTest.php +++ b/Tests/Functional/Persistence/TranslatedSiteContentTest.php @@ -557,7 +557,7 @@ public static function contentOnPartiallyTranslatedPageDataProvider(): array */ #[DataProvider('contentOnPartiallyTranslatedPageDataProvider')] #[Test] - public function contentOnPartiallyTranslatedPage(string $fallbackType, array $fallbackChain, array $visibleHeaders): void + public function contentOnPartiallyTranslatedPage(string $fallbackType, array $fallbackChain, array $visibleRecordHeaders): void { $this->writeSiteConfiguration( 'test', @@ -582,14 +582,14 @@ public function contentOnPartiallyTranslatedPage(string $fallbackType, array $fa $this->getRequestSectionHasRecordConstraint() ->setTable(self::TABLE_Content) ->setField('header') - ->setValues(...$visibleHeaders) + ->setValues(...$visibleRecordHeaders) ); self::assertThat( $responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint() ->setTable(self::TABLE_Content) ->setField('header') - ->setValues(...$this->getNonVisibleHeaders($visibleHeaders)) + ->setValues(...$this->getNonVisibleHeaders($visibleRecordHeaders)) ); } diff --git a/Tests/Functional/Validation/Validator/UrlValidatorTest.php b/Tests/Functional/Validation/Validator/UrlValidatorTest.php index 53f532540..403b87abf 100644 --- a/Tests/Functional/Validation/Validator/UrlValidatorTest.php +++ b/Tests/Functional/Validation/Validator/UrlValidatorTest.php @@ -111,10 +111,10 @@ public static function urlDataProvider(): array #[DataProvider('urlDataProvider')] #[Test] - public function urlValidatorDetectsUrlsCorrectly($value, $expected): void + public function urlValidatorDetectsUrlsCorrectly($value, $isValid): void { $validator = new UrlValidator(); $validator->setOptions([]); - self::assertSame($expected, !$validator->validate($value)->hasErrors()); + self::assertSame($isValid, !$validator->validate($value)->hasErrors()); } }