From 1037b0b64ff2004a653201563c797ff6fbfaa438 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 --- .../FormDataProvider/TcaCheckboxItemsTest.php | 4 ++-- Tests/Unit/Utility/BackendUtilityTest.php | 23 +++---------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Tests/Unit/Form/FormDataProvider/TcaCheckboxItemsTest.php b/Tests/Unit/Form/FormDataProvider/TcaCheckboxItemsTest.php index 77b7ae54c..fca2cbcf1 100644 --- a/Tests/Unit/Form/FormDataProvider/TcaCheckboxItemsTest.php +++ b/Tests/Unit/Form/FormDataProvider/TcaCheckboxItemsTest.php @@ -381,13 +381,13 @@ public static function checkboxConfigurationDataProvider(): array #[DataProvider('checkboxConfigurationDataProvider')] #[Test] - public function addDataKeepExistingItems(array $input, array $expectedResult): void + public function addDataKeepExistingItems(array $input, array $expected): void { $languageService = $this->createMock(LanguageService::class); $GLOBALS['LANG'] = $languageService; $languageService->method('sL')->with(self::anything())->willReturnArgument(0); - self::assertSame($expectedResult, (new TcaCheckboxItems())->addData($input)); + self::assertSame($expected, (new TcaCheckboxItems())->addData($input)); } #[Test] diff --git a/Tests/Unit/Utility/BackendUtilityTest.php b/Tests/Unit/Utility/BackendUtilityTest.php index 61ad9a4d4..3e4cfe4cb 100644 --- a/Tests/Unit/Utility/BackendUtilityTest.php +++ b/Tests/Unit/Utility/BackendUtilityTest.php @@ -37,12 +37,6 @@ final class BackendUtilityTest extends UnitTestCase { protected bool $resetSingletonInstances = true; - /////////////////////////////////////// - // Tests concerning calcAge - /////////////////////////////////////// - /** - * Data provider for calcAge function - */ public static function calcAgeDataProvider(): array { return [ @@ -124,12 +118,6 @@ public function calcAgeReturnsExpectedValues(int $seconds, string $expectedLabel self::assertSame($expectedLabel, BackendUtility::calcAge($seconds)); } - /////////////////////////////////////// - // Tests concerning getProcessedValue - /////////////////////////////////////// - /** - * @see https://forge.typo3.org/issues/20994 - */ #[Test] public function getProcessedValueForZeroStringIsZero(): void { @@ -144,9 +132,7 @@ public function getProcessedValueForZeroStringIsZero(): void ], ], ]; - $GLOBALS['LANG'] = $this->createMock(LanguageService::class); - self::assertEquals('0', BackendUtility::getProcessedValue('tt_content', 'header', '0')); } @@ -587,12 +573,9 @@ public static function inputTypeDateDisplayOptions(): array ]; } - /** - * @param bool|int $input - */ #[DataProvider('inputTypeDateDisplayOptions')] #[Test] - public function getProcessedValueHandlesAgeDisplayCorrectly($input, string $expected): void + public function getProcessedValueHandlesAgeDisplayCorrectly(bool|int $input, string $expected): void { $languageServiceMock = $this->createMock(LanguageService::class); $languageServiceMock->method('sL')->willReturn(' min| hrs| days| yrs| min| hour| day| year'); @@ -907,7 +890,7 @@ public static function getLabelFromItemListMergedReturnsCorrectFieldsDataProvide 'no field found' => [ 'pageId' => 123, 'table' => 'tt_content', - 'col' => 'menu_type', + 'column' => 'menu_type', 'key' => '10', 'tca' => [ 'columns' => [ @@ -927,7 +910,7 @@ public static function getLabelFromItemListMergedReturnsCorrectFieldsDataProvide 'no tsconfig set' => [ 'pageId' => 123, 'table' => 'tt_content', - 'col' => 'menu_type', + 'column' => 'menu_type', 'key' => '1', 'tca' => [ 'columns' => [