Skip to content

Commit

Permalink
[TASK] Update invalid test data providers
Browse files Browse the repository at this point in the history
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 sebastianbergmann/phpunit#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 <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: core-ci <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
  • Loading branch information
lolli42 authored and sbuerk committed Apr 15, 2024
1 parent 3945711 commit 1037b0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Tests/Unit/Form/FormDataProvider/TcaCheckboxItemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 3 additions & 20 deletions Tests/Unit/Utility/BackendUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down Expand Up @@ -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
{
Expand All @@ -144,9 +132,7 @@ public function getProcessedValueForZeroStringIsZero(): void
],
],
];

$GLOBALS['LANG'] = $this->createMock(LanguageService::class);

self::assertEquals('0', BackendUtility::getProcessedValue('tt_content', 'header', '0'));
}

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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' => [
Expand All @@ -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' => [
Expand Down

0 comments on commit 1037b0b

Please sign in to comment.