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 7f7b999 commit d88b8cd
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 163 deletions.
44 changes: 22 additions & 22 deletions 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
6 changes: 3 additions & 3 deletions Tests/Functional/DataHandling/Regular/MinValueTest.php
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 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
6 changes: 3 additions & 3 deletions Tests/Functional/Resource/Driver/LocalDriverTest.php
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
60 changes: 30 additions & 30 deletions Tests/Functional/Resource/StorageRepositoryTest.php
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 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,53 @@ public static function emailSoftReferenceParserTestDataProvider(): array
{
return [
'Simple email address found' => [
'[email protected]',
'content' => '[email protected]',
'elements' => [
'expectedContent' => '[email protected]',
'expectedElements' => [
2 => [
'matchString' => '[email protected]',
],
],
'hasMatched' => true,
'expectedHasMatched' => true,
],
'Multiple email addresses found' => [
'This is my first email: [email protected] and this is my second email: [email protected]',
'content' => 'This is my first email: [email protected] and this is my second email: [email protected]',
'elements' => [
'expectedContent' => 'This is my first email: [email protected] and this is my second email: [email protected]',
'expectedElements' => [
2 => [
'matchString' => '[email protected]',
],
5 => [
'matchString' => '[email protected]',
],
],
'hasMatched' => true,
'expectedHasMatched' => true,
],
'Invalid emails are ignored' => [
'[email protected]
'content' => '[email protected]
[email protected]
[email protected]
abc#[email protected]
[email protected]
abc.def@mail#archive.com
abc.def@mail
[email protected]',
'content' => '',
'elements' => [],
'hasMatched' => false,
'expectedContent' => '',
'expectedElements' => [],
'expectedHasMatched' => false,
],
'E-Mails in html match' => [
'<a href="mailto:[email protected]">[email protected]</a>',
'content' => '<a href="mailto:[email protected]">[email protected]</a>',
'elements' => [
'expectedContent' => '<a href="mailto:[email protected]">[email protected]</a>',
'expectedElements' => [
2 => [
'matchString' => '[email protected]',
],
5 => [
'matchString' => '[email protected]',
],
],
'hasMatched' => true,
'expectedHasMatched' => true,
],
];
}
Expand Down
Loading

0 comments on commit d88b8cd

Please sign in to comment.