Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI authored Sep 29, 2023
2 parents 63901b5 + f00641b commit 488e20c
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
]],
'php_unit_strict' => true,
'php_unit_test_case_static_method_calls' => true,
'php_unit_data_provider_name' => true,
'php_unit_data_provider_return_type' => true,
'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-var']],
'single_line_throw' => false,
'static_lambda' => true,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^0.17",
"rector/rector": "^0.18",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/css-selector": "^5.4 || ^6.2",
"symfony/filesystem": "^5.4 || ^6.2",
Expand Down
8 changes: 8 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
use Rector\Config\RectorConfig;
use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector;
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -30,12 +34,16 @@

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);

$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
$rectorConfig->skip([
CountOnNullRector::class,
ExceptionHandlerTypehintRector::class,
AddSeeTestAnnotationRector::class,
PreferPHPUnitThisCallRector::class,
]);
};
12 changes: 5 additions & 7 deletions tests/DependencyInjection/Compiler/CmfRouterAutoRegisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
final class CmfRouterAutoRegisterTest extends AbstractCompilerPassTestCase
{
/**
* @dataProvider providerRoutedAutoRegister
* @dataProvider provideRouterAutoRegisterCases
*/
public function testRouterAutoRegister(bool $enabled, int $priority): void
{
Expand Down Expand Up @@ -56,14 +56,12 @@ public function testRouterAutoRegister(bool $enabled, int $priority): void
}

/**
* @return array<string, array{bool, int}>
* @return iterable<string, array{bool, int}>
*/
public function providerRoutedAutoRegister(): array
public function provideRouterAutoRegisterCases(): iterable
{
return [
'enabled router' => [true, 42],
'disabled router' => [false, 84],
];
yield 'enabled router' => [true, 42];
yield 'disabled router' => [false, 84];
}

protected function registerCompilerPass(ContainerBuilder $container): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Entity/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function testLoadSnapshotToPage(): void
}

/**
* @dataProvider blockProvider
* @dataProvider provideLoadBlockCases
*
* @param array<string, mixed> $content
*
Expand All @@ -172,7 +172,7 @@ public function testLoadBlock(array $content): void
/**
* @phpstan-return iterable<array{BlockContent}>
*/
public function blockProvider(): iterable
public function provideLoadBlockCases(): iterable
{
$datetime = new \DateTime();

Expand Down
12 changes: 6 additions & 6 deletions tests/Functional/Admin/BlockAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function provideCrudUrlsCases(): iterable
}

/**
* @dataProvider provideFormUrlsCases
* @dataProvider provideFormsUrlsCases
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $fieldValues
Expand All @@ -80,7 +80,7 @@ public function testFormsUrls(string $url, array $parameters, string $button, ar
*
* @phpstan-return iterable<array{0: string, 1: array<string, mixed>, 2: string, 3?: array<string, mixed>}>
*/
public static function provideFormUrlsCases(): iterable
public static function provideFormsUrlsCases(): iterable
{
yield 'Create Block - Text' => ['/admin/tests/app/sonatapageblock/create', [
'uniqid' => 'block',
Expand All @@ -98,7 +98,7 @@ public static function provideFormUrlsCases(): iterable
}

/**
* @dataProvider provideSwitchParentCases
* @dataProvider provideSwitchParentForBlockCases
*
* @param array{block_id?: int|string|null, parent_id?: int|string|null} $parameters
*/
Expand All @@ -122,7 +122,7 @@ public function testSwitchParentForBlock(array $parameters, bool $success): void
*
* @phpstan-return iterable<array{0: array{block_id?: int|string|null, parent_id?: int|string|null}, 1: bool}>
*/
public static function provideSwitchParentCases(): iterable
public static function provideSwitchParentForBlockCases(): iterable
{
yield 'Missing all parameters' => [[], false];

Expand All @@ -147,7 +147,7 @@ public static function provideSwitchParentCases(): iterable
}

/**
* @dataProvider provideDispositionCases
* @dataProvider provideSavePositionForBlockCases
*
* @param array{disposition?: array<array{id: int|string, position: int|numeric-string}>} $parameters
*/
Expand Down Expand Up @@ -177,7 +177,7 @@ public function testSavePositionForBlock(array $parameters, bool $success): void
*
* @phpstan-return iterable<array{0: array{disposition?: array<array{id: int|string, position: int|numeric-string}>}, 1: bool}>
*/
public static function provideDispositionCases(): iterable
public static function provideSavePositionForBlockCases(): iterable
{
yield 'Missing disposition' => [[], false];

Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Admin/PageAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testRedirectWithSiteSelectedWhenThereIsOnlyOneSite(): void
}

/**
* @dataProvider provideFormUrlsCases
* @dataProvider provideFormsUrlsCases
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $fieldValues
Expand All @@ -124,7 +124,7 @@ public function testFormsUrls(string $url, array $parameters, string $button, ar
*
* @phpstan-return iterable<array{0: string, 1: array<string, mixed>, 2: string, 3?: array<string, mixed>}>
*/
public static function provideFormUrlsCases(): iterable
public static function provideFormsUrlsCases(): iterable
{
yield 'Create Page' => ['/admin/tests/app/sonatapagepage/create', [
'uniqid' => 'page',
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Admin/SharedBlockAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function provideCrudUrlsCases(): iterable
}

/**
* @dataProvider provideFormUrlsCases
* @dataProvider provideFormsUrlsCases
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $fieldValues
Expand All @@ -77,7 +77,7 @@ public function testFormsUrls(string $url, array $parameters, string $button, ar
*
* @phpstan-return iterable<array{0: string, 1: array<string, mixed>, 2: string, 3?: array<string, mixed>}>
*/
public static function provideFormUrlsCases(): iterable
public static function provideFormsUrlsCases(): iterable
{
// Blocks From SonataBlockBundle
yield 'Create Shared Block - Text' => ['/admin/tests/app/sonatapageblock/shared/create', [
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Admin/SiteAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function provideCrudUrlsCases(): iterable
}

/**
* @dataProvider provideFormUrlsCases
* @dataProvider provideFormsUrlsCases
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $fieldValues
Expand All @@ -74,7 +74,7 @@ public function testFormsUrls(string $url, array $parameters, string $button, ar
*
* @phpstan-return iterable<array{0: string, 1: array<string, mixed>, 2: string, 3?: array<string, mixed>}>
*/
public static function provideFormUrlsCases(): iterable
public static function provideFormsUrlsCases(): iterable
{
yield 'Create Site' => ['/admin/tests/app/sonatapagesite/create', [
'uniqid' => 'site',
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Admin/SnapshotAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function provideCrudUrlsCases(): iterable
}

/**
* @dataProvider provideFormUrlsCases
* @dataProvider provideFormsUrlsCases
*
* @param array<string, mixed> $parameters
* @param array<string, mixed> $fieldValues
Expand All @@ -75,7 +75,7 @@ public function testFormsUrls(string $url, array $parameters, string $button, ar
*
* @phpstan-return iterable<array{0: string, 1: array<string, mixed>, 2: string, 3?: array<string, mixed>}>
*/
public static function provideFormUrlsCases(): iterable
public static function provideFormsUrlsCases(): iterable
{
yield 'Create Snapshot' => ['/admin/tests/app/sonatapagesnapshot/create', [
'uniqid' => 'snapshot',
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Command/CleanupSnapshotsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testThrowExceptionOnInvalidValue(): void
}

/**
* @dataProvider provideKeepSnapshotsCases
* @dataProvider provideDoCleanupsCases
*
* @param array{'--site'?: array<int>, '--keep-snapshots'?: int} $input
*/
Expand All @@ -65,7 +65,7 @@ public function testDoCleanups(array $input, int $snapshotCount): void
*
* @phpstan-return iterable<array{0: array{'--site'?: array<int>, '--keep-snapshots'?: int}, 1: int}>
*/
public static function provideKeepSnapshotsCases(): iterable
public static function provideDoCleanupsCases(): iterable
{
yield 'Keep no snapshots' => [[
'--keep-snapshots' => 0,
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Command/CreateSiteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
}

/**
* @dataProvider provideSiteCreationOptions
* @dataProvider provideCreateSiteCases
*
* @param array{
* '--no-confirmation'?: bool,
Expand Down Expand Up @@ -77,7 +77,7 @@ public function testCreateSite(array $commandInput, array $questionInputs, bool
* 2: bool,
* }>
*/
public static function provideSiteCreationOptions(): iterable
public static function provideCreateSiteCases(): iterable
{
yield 'Minimal interactive without confirmation' => [
[],
Expand Down
38 changes: 16 additions & 22 deletions tests/Functional/Entity/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public function disableAutoIncrement(string $class): void
}

/**
* @return array{\DateTime, ?int, array<string, mixed>}[]
* @return iterable<array{\DateTime, ?int, array<string, mixed>}>
*/
public function createProvider(): array
public function createProvider(): iterable
{
$datetime = new \DateTime();

Expand All @@ -125,19 +125,16 @@ public function createProvider(): array
'include_homepage_link' => true,
'context' => false,
];

return [
[$datetime, 0, []],
[$datetime, 0, $settings],
[$datetime, null, []],
[$datetime, null, $settings],
];
yield [$datetime, 0, []];
yield [$datetime, 0, $settings];
yield [$datetime, null, []];
yield [$datetime, null, $settings];
}

/**
* @return array{\DateTime, int|string|null, array<string, mixed>}[]
* @return iterable<array{\DateTime, int|string|null, array<string, mixed>}>
*/
public function loadProvider(): array
public function loadProvider(): iterable
{
$datetime = new \DateTime();

Expand All @@ -152,17 +149,14 @@ public function loadProvider(): array
'include_homepage_link' => true,
'context' => false,
];

return [
[$datetime, 0, []],
[$datetime, 0, $settings],
[$datetime, null, []],
[$datetime, null, $settings],
[$datetime, '0', []],
[$datetime, '0', $settings],
[$datetime, '', []],
[$datetime, '', $settings],
];
yield [$datetime, 0, []];
yield [$datetime, 0, $settings];
yield [$datetime, null, []];
yield [$datetime, null, $settings];
yield [$datetime, '0', []];
yield [$datetime, '0', $settings];
yield [$datetime, '', []];
yield [$datetime, '', $settings];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Frontend/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testPageRenderFromPageWhenUserIsAnEditor(): void
}

/**
* @dataProvider providePages
* @dataProvider providePageRenderCases
*
* @param array<string> $shouldContain
* @param array<string> $shouldNotContain
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testPageRender(PageInterface $page, string $url, int $statusCode
*
* @phpstan-return iterable<array{0: PageInterface, 1: string, 2: int, 3: array<string>, 4: array<string>}>
*/
public static function providePages(): iterable
public static function providePageRenderCases(): iterable
{
yield 'CMS Page' => [(static function () {
$page = new SonataPagePage();
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Frontend/SnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testPageRenderFromSnapshot(): void
}

/**
* @dataProvider provideSnapshots
* @dataProvider provideSnapshotRenderCases
*
* @param array<string> $shouldContain
* @param array<string> $shouldNotContain
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testSnapshotRender(PageInterface $page, string $url, int $status
*
* @phpstan-return iterable<array{0: PageInterface, 1: string, 2: int, 3: array<string>, 4: array<string>}>
*/
public static function provideSnapshots(): iterable
public static function provideSnapshotRenderCases(): iterable
{
yield 'CMS Snapshot' => [(static function () {
$page = new SonataPagePage();
Expand Down
14 changes: 10 additions & 4 deletions tests/Site/HostPathSiteSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
final class HostPathSiteSelectorTest extends TestCase
{
/**
* @dataProvider siteProvider
* @dataProvider provideSiteCases
*/
public function testSite(string $expectedName, string $url, string $expectedPath = '/'): void
{
Expand All @@ -45,7 +45,10 @@ public function testSite(string $expectedName, string $url, string $expectedPath
static::assertSame($site->getLocale(), $event->getRequest()->attributes->get('_locale'));
}

public function siteProvider(): \Generator
/**
* @return iterable<array{0: string, 1: string, 2?: string}>
*/
public function provideSiteCases(): iterable
{
yield ['Site 0', 'http://www.example.com/test0'];
yield ['Site 1', 'http://www.example.com/test1'];
Expand All @@ -59,7 +62,7 @@ public function siteProvider(): \Generator
}

/**
* @dataProvider siteWithRedirectProvider
* @dataProvider provideSiteWithRedirectCases
*/
public function testSiteWithRedirect(string $expectedRedirectUri, string $url, string $path): void
{
Expand All @@ -75,7 +78,10 @@ public function testSiteWithRedirect(string $expectedRedirectUri, string $url, s
static::assertNull($event->getRequest()->attributes->get('_locale'));
}

public function siteWithRedirectProvider(): \Generator
/**
* @return iterable<array{string, string, string}>
*/
public function provideSiteWithRedirectCases(): iterable
{
yield ['//www.example.com/test2', 'http://www.example.com/test5', '/test5'];
yield ['//www.example.com/test2', 'http://www.example.com/test6', '/test6'];
Expand Down
Loading

0 comments on commit 488e20c

Please sign in to comment.