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 ad1f129 commit 42ad9bb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function overrideConfigurationFromFlexFormSettingsDataProvider():
],
],
],
[
'expected' => [
'booleanField' => '1',
],
];
Expand Down Expand Up @@ -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']);
Expand Down
21 changes: 4 additions & 17 deletions Tests/Functional/Mvc/Controller/ControllerArgumentsMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'];

Expand Down Expand Up @@ -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',
],
];
}
Expand Down
32 changes: 16 additions & 16 deletions Tests/Functional/Persistence/QueryLocalizedDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
[
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -680,7 +680,7 @@ public static function queryFirst5PostsDataProvider(): array
],
],
[
'language' => 1,
'languageUid' => 1,
'overlay' => LanguageAspect::OVERLAYS_OFF,
'expected' => [
[
Expand Down Expand Up @@ -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' => [
[
Expand Down Expand Up @@ -897,7 +897,7 @@ public static function queryPostsByPropertyDataProvider(): array
],
],
[
'language' => 1,
'languageUid' => 1,
'overlay' => LanguageAspect::OVERLAYS_ON,
'expected' => [
[
Expand All @@ -918,7 +918,7 @@ public static function queryPostsByPropertyDataProvider(): array
],
],
[
'language' => 1,
'languageUid' => 1,
'overlay' => LanguageAspect::OVERLAYS_ON_WITH_FLOATING,
'expected' => [
[
Expand Down Expand Up @@ -954,7 +954,7 @@ public static function queryPostsByPropertyDataProvider(): array
],
],
[
'language' => 1,
'languageUid' => 1,
'overlay' => LanguageAspect::OVERLAYS_OFF,
'expected' => [
[
Expand Down Expand Up @@ -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' => [
[
Expand All @@ -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,
],
Expand Down
6 changes: 3 additions & 3 deletions Tests/Functional/Persistence/TranslatedSiteContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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))
);
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Validation/Validator/UrlValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 42ad9bb

Please sign in to comment.