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 04bb63b commit 9766ab8
Show file tree
Hide file tree
Showing 36 changed files with 363 additions and 389 deletions.
16 changes: 10 additions & 6 deletions typo3/sysext/adminpanel/Tests/Unit/Utility/StateUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ public static function tsConfigDisabledDataProvider(): array
[],
],
'all modules disabled' => [
'admPanel.' => [
'enable.' => [
'all' => 0,
[
'admPanel.' => [
'enable.' => [
'all' => 0,
],
],
],
],
'single module configured, disabled' => [
'admPanel.' => [
'enable.' => [
'preview' => 0,
[
'admPanel.' => [
'enable.' => [
'preview' => 0,
],
],
],
],
Expand Down
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 typo3/sysext/backend/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
44 changes: 22 additions & 22 deletions typo3/sysext/core/Tests/Functional/Command/CliCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ public function setUp(): void
public static function commandTestDataProvider(): array
{
return [
['command' => 'cleanup:localprocessedfiles', 'args' => ['-v'], 'code' => 0],
['command' => 'cache:flush', 'args' => [], 'code' => 0],
['command' => 'cache:warmup', 'args' => [], 'code' => 0],
['command' => 'cleanup:flexforms', 'args' => [], 'code' => 0],
['command' => 'cleanup:deletedrecords', 'args' => [], 'code' => 0],
['command' => 'cleanup:orphanrecords', 'args' => [], 'code' => 0],
['command' => 'cleanup:previewlinks', 'args' => [], 'code' => 0],
['command' => 'cleanup:versions', 'args' => [], 'code' => 0],
['command' => 'extension:list', 'args' => [], 'code' => 0],
['command' => 'extension:setup', 'args' => [], 'code' => 0],
['command' => 'extension:deactivate workspaces', 'args' => [], 'code' => 0],
['command' => 'extension:activate workspaces', 'args' => [], 'code' => 0],
['command' => 'language:update', 'args' => [], 'code' => 0],
['command' => 'mailer:spool:send', 'args' => [], 'code' => 1],
['command' => 'redirects:checkintegrity', 'args' => [], 'code' => 0],
['command' => 'redirects:cleanup', 'args' => [], 'code' => 0],
['command' => 'referenceindex:update', 'args' => ['--check'], 'code' => 0],
['command' => 'scheduler:run', 'args' => [], 'code' => 0],
['command' => 'site:list', 'args' => [], 'code' => 0],
['command' => 'site:show show-me', 'args' => [], 'code' => 0],
['command' => 'syslog:list', 'args' => [], 'code' => 0],
['command' => 'upgrade:list', 'args' => [], 'code' => 0],
['command' => 'cleanup:localprocessedfiles', 'args' => ['-v'], 'expectedExitCode' => 0],
['command' => 'cache:flush', 'args' => [], 'expectedExitCode' => 0],
['command' => 'cache:warmup', 'args' => [], 'expectedExitCode' => 0],
['command' => 'cleanup:flexforms', 'args' => [], 'expectedExitCode' => 0],
['command' => 'cleanup:deletedrecords', 'args' => [], 'expectedExitCode' => 0],
['command' => 'cleanup:orphanrecords', 'args' => [], 'expectedExitCode' => 0],
['command' => 'cleanup:previewlinks', 'args' => [], 'expectedExitCode' => 0],
['command' => 'cleanup:versions', 'args' => [], 'expectedExitCode' => 0],
['command' => 'extension:list', 'args' => [], 'expectedExitCode' => 0],
['command' => 'extension:setup', 'args' => [], 'expectedExitCode' => 0],
['command' => 'extension:deactivate workspaces', 'args' => [], 'expectedExitCode' => 0],
['command' => 'extension:activate workspaces', 'args' => [], 'expectedExitCode' => 0],
['command' => 'language:update', 'args' => [], 'expectedExitCode' => 0],
['command' => 'mailer:spool:send', 'args' => [], 'expectedExitCode' => 1],
['command' => 'redirects:checkintegrity', 'args' => [], 'expectedExitCode' => 0],
['command' => 'redirects:cleanup', 'args' => [], 'expectedExitCode' => 0],
['command' => 'referenceindex:update', 'args' => ['--check'], 'expectedExitCode' => 0],
['command' => 'scheduler:run', 'args' => [], 'expectedExitCode' => 0],
['command' => 'site:list', 'args' => [], 'expectedExitCode' => 0],
['command' => 'site:show show-me', 'args' => [], 'expectedExitCode' => 0],
['command' => 'syslog:list', 'args' => [], 'expectedExitCode' => 0],
['command' => 'upgrade:list', 'args' => [], 'expectedExitCode' => 0],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public static function valuesLowerThanMinResetToEmptyStringDataProvider(): itera

#[DataProvider('valuesLowerThanMinResetToEmptyStringDataProvider')]
#[Test]
public function valuesLowerThanMinResetToEmptyString(string $string, string $expected): void
public function valuesLowerThanMinResetToEmptyString(string $value, string $expected): void
{
// Should work for type=input and type=text (except RTE).
$actionService = new ActionService();
$map = $actionService->createNewRecord('tt_content', 1, [
'tx_testdatahandler_input_minvalue' => $string,
'tx_testdatahandler_text_minvalue' => $string,
'tx_testdatahandler_input_minvalue' => $value,
'tx_testdatahandler_text_minvalue' => $value,
]);
$newRecordId = reset($map['tt_content']);
$newRecord = BackendUtility::getRecord('tt_content', $newRecordId);
Expand Down
38 changes: 19 additions & 19 deletions typo3/sysext/core/Tests/Functional/Imaging/IconFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

final class IconFactoryTest extends FunctionalTestCase
{
protected IconFactory $subject;
protected string $notRegisteredIconIdentifier = 'my-super-unregistered-identifier';
protected string $registeredIconIdentifier = 'actions-close';
protected string $registeredSpinningIconIdentifier = 'spinning-icon';
private IconFactory $subject;
private string $notRegisteredIconIdentifier = 'my-super-unregistered-identifier';
private string $registeredIconIdentifier = 'actions-close';
private string $registeredSpinningIconIdentifier = 'spinning-icon';

/**
* Simulate a tt_content record
*/
protected array $mockRecord = [
private array $mockRecord = [
'header' => 'dummy content header',
'uid' => '1',
'pid' => '1',
Expand Down Expand Up @@ -68,10 +68,10 @@ protected function setUp(): void
public static function differentSizesDataProvider(): array
{
return [
['size ' . Icon::SIZE_DEFAULT => ['input' => Icon::SIZE_DEFAULT, 'expected' => Icon::SIZE_DEFAULT]],
['size ' . Icon::SIZE_SMALL => ['input' => Icon::SIZE_SMALL, 'expected' => Icon::SIZE_SMALL]],
['size ' . Icon::SIZE_MEDIUM => ['input' => Icon::SIZE_MEDIUM, 'expected' => Icon::SIZE_MEDIUM]],
['size ' . Icon::SIZE_LARGE => ['input' => Icon::SIZE_LARGE, 'expected' => Icon::SIZE_LARGE]],
'size ' . Icon::SIZE_DEFAULT => ['size' => Icon::SIZE_DEFAULT, 'expected' => Icon::SIZE_DEFAULT],
'size ' . Icon::SIZE_SMALL => ['size' => Icon::SIZE_SMALL, 'expected' => Icon::SIZE_SMALL],
'size ' . Icon::SIZE_MEDIUM => ['size' => Icon::SIZE_MEDIUM, 'expected' => Icon::SIZE_MEDIUM],
'size ' . Icon::SIZE_LARGE => ['size' => Icon::SIZE_LARGE, 'expected' => Icon::SIZE_LARGE],
];
}

Expand All @@ -95,21 +95,21 @@ public function getIconByIdentifierReturnsIconWithCorrectMarkupIfRegisteredIconI

#[DataProvider('differentSizesDataProvider')]
#[Test]
public function getIconByIdentifierAndSizeReturnsIconWithCorrectMarkupIfRegisteredIconIdentifierIsUsed($size): void
public function getIconByIdentifierAndSizeReturnsIconWithCorrectMarkupIfRegisteredIconIdentifierIsUsed(string $size, string $expected): void
{
self::assertStringContainsString(
'<span class="t3js-icon icon icon-size-' . $size['expected'] . ' icon-state-default icon-actions-close" data-identifier="actions-close" aria-hidden="true">',
$this->subject->getIcon($this->registeredIconIdentifier, $size['input'])->render()
'<span class="t3js-icon icon icon-size-' . $expected . ' icon-state-default icon-actions-close" data-identifier="actions-close" aria-hidden="true">',
$this->subject->getIcon($this->registeredIconIdentifier, $size)->render()
);
}

#[DataProvider('differentSizesDataProvider')]
#[Test]
public function getIconByIdentifierAndSizeAndWithOverlayReturnsIconWithCorrectOverlayMarkupIfRegisteredIconIdentifierIsUsed($size): void
public function getIconByIdentifierAndSizeAndWithOverlayReturnsIconWithCorrectOverlayMarkupIfRegisteredIconIdentifierIsUsed(string $size, string $expected): void
{
self::assertStringContainsString(
'<span class="icon-overlay icon-overlay-readonly">',
$this->subject->getIcon($this->registeredIconIdentifier, $size['input'], 'overlay-readonly')->render()
$this->subject->getIcon($this->registeredIconIdentifier, $size, 'overlay-readonly')->render()
);
}

Expand All @@ -124,11 +124,11 @@ public function getIconReturnsNotFoundIconWithCorrectMarkupIfUnregisteredIdentif

#[DataProvider('differentSizesDataProvider')]
#[Test]
public function getIconByIdentifierAndSizeReturnsNotFoundIconWithCorrectMarkupIfUnregisteredIdentifierIsUsed(array $size): void
public function getIconByIdentifierAndSizeReturnsNotFoundIconWithCorrectMarkupIfUnregisteredIdentifierIsUsed(string $size, string $expected): void
{
self::assertStringContainsString(
'<span class="t3js-icon icon icon-size-' . $size['expected'] . ' icon-state-default icon-default-not-found" data-identifier="default-not-found" aria-hidden="true">',
$this->subject->getIcon($this->notRegisteredIconIdentifier, $size['input'])->render()
'<span class="t3js-icon icon icon-size-' . $expected . ' icon-state-default icon-default-not-found" data-identifier="default-not-found" aria-hidden="true">',
$this->subject->getIcon($this->notRegisteredIconIdentifier, $size)->render()
);
}

Expand All @@ -152,11 +152,11 @@ public function getIconReturnsCorrectMarkupIfIconIsRegisteredAsSpinningIcon(): v

#[DataProvider('differentSizesDataProvider')]
#[Test]
public function getIconByIdentifierAndSizeAndOverlayReturnsNotFoundIconWithCorrectMarkupIfUnregisteredIdentifierIsUsed(array $size): void
public function getIconByIdentifierAndSizeAndOverlayReturnsNotFoundIconWithCorrectMarkupIfUnregisteredIdentifierIsUsed(string $size, string $expected): void
{
self::assertStringContainsString(
'<span class="icon-overlay icon-overlay-readonly">',
$this->subject->getIcon($this->notRegisteredIconIdentifier, $size['input'], 'overlay-readonly')->render()
$this->subject->getIcon($this->notRegisteredIconIdentifier, $size, 'overlay-readonly')->render()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ public static function getSpecificFileInformationDataProvider(): array

#[DataProvider('getSpecificFileInformationDataProvider')]
#[Test]
public function getSpecificFileInformationReturnsRequestedFileInformation(string|int $expectedValue, string $property): void
public function getSpecificFileInformationReturnsRequestedFileInformation(string|int $expectedValue, string $propertyName): void
{
copy(__DIR__ . '/Fixtures/Dummy.html', $this->baseDirectory . '/Dummy.html');
if (in_array($property, ['mtime', 'ctime', 'atime'])) {
if (in_array($propertyName, ['mtime', 'ctime', 'atime'])) {
$expectedValue = filemtime($this->baseDirectory . '/Dummy.html');
}
$subject = $this->getDefaultInitializedSubject();
$subject->setStorageUid(5);
self::assertSame($expectedValue, $subject->getSpecificFileInformation($this->baseDirectory . '/Dummy.html', '/', $property));
self::assertSame($expectedValue, $subject->getSpecificFileInformation($this->baseDirectory . '/Dummy.html', '/', $propertyName));
}

#[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,46 +164,46 @@ public static function isWithinFileMountBoundariesDataProvider(): array
{
return [
'Access to file in ro file mount denied for write request' => [
'$targetDirectory' => 'fooBaz',
'$fileMountFolder' => 'fooBaz',
'$isFileMountReadOnly' => true,
'$checkWriteAccess' => true,
'$expectedResult' => false,
'targetDirectory' => 'fooBaz',
'fileMountFolder' => 'fooBaz',
'isFileMountReadOnly' => true,
'checkWriteAccess' => true,
'expectedResult' => false,
],
'Access to file in ro file mount allowed for read request' => [
'$targetDirectory' => 'fooBaz',
'$fileMountFolder' => 'fooBaz',
'$isFileMountReadOnly' => true,
'$checkWriteAccess' => false,
'$expectedResult' => true,
'targetDirectory' => 'fooBaz',
'fileMountFolder' => 'fooBaz',
'isFileMountReadOnly' => true,
'checkWriteAccess' => false,
'expectedResult' => true,
],
'Access to file in rw file mount allowed for write request' => [
'$targetDirectory' => 'fooBaz',
'$fileMountFolder' => 'fooBaz',
'$isFileMountReadOnly' => false,
'$checkWriteAccess' => true,
'$expectedResult' => true,
'targetDirectory' => 'fooBaz',
'fileMountFolder' => 'fooBaz',
'isFileMountReadOnly' => false,
'checkWriteAccess' => true,
'expectedResult' => true,
],
'Access to file in rw file mount allowed for read request' => [
'$targetDirectory' => 'fooBaz',
'$fileMountFolder' => 'fooBaz',
'$isFileMountReadOnly' => false,
'$checkWriteAccess' => false,
'$expectedResult' => true,
'targetDirectory' => 'fooBaz',
'fileMountFolder' => 'fooBaz',
'isFileMountReadOnly' => false,
'checkWriteAccess' => false,
'expectedResult' => true,
],
'Access to file not in file mount denied for write request' => [
'$targetDirectory' => 'fooBaz',
'$fileMountFolder' => 'barBaz',
'$isFileMountReadOnly' => false,
'$checkWriteAccess' => true,
'$expectedResult' => false,
'targetDirectory' => 'fooBaz',
'fileMountFolder' => 'barBaz',
'isFileMountReadOnly' => false,
'checkWriteAccess' => true,
'expectedResult' => false,
],
'Access to file not in file mount denied for read request' => [
'$targetDirectory' => 'fooBaz',
'$fileMountFolder' => 'barBaz',
'$isFileMountReadOnly' => false,
'$checkWriteAccess' => false,
'$expectedResult' => false,
'targetDirectory' => 'fooBaz',
'fileMountFolder' => 'barBaz',
'isFileMountReadOnly' => false,
'checkWriteAccess' => false,
'expectedResult' => false,
],
];
}
Expand Down
6 changes: 3 additions & 3 deletions typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ public static function numberValueCheckRecognizesDecimalStringValuesAsFloatValue

#[DataProvider('numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectlyDataProvider')]
#[Test]
public function numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectly(string $value, string $expectedReturnValue): void
public function numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectly(string $input, string $expected): void
{
$tcaFieldConf = [
'type' => 'number',
'format' => 'decimal',
];
$returnValue = $this->subject->_call('checkValueForNumber', $value, $tcaFieldConf);
self::assertSame($expectedReturnValue, $returnValue['value']);
$returnValue = $this->subject->_call('checkValueForNumber', $input, $tcaFieldConf);
self::assertSame($expected, $returnValue['value']);
}

/**
Expand Down
Loading

0 comments on commit 9766ab8

Please sign in to comment.