Skip to content

Commit

Permalink
Merge 3.x into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI authored Oct 4, 2023
2 parents 7055f5d + 51bf0d1 commit f5897b5
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 146 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 @@ -43,7 +43,7 @@
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^0.17",
"rector/rector": "^0.18",
"symfony/phpunit-bridge": "^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"vimeo/psalm": "^5.0"
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,
]);
};
46 changes: 21 additions & 25 deletions tests/Helper/NumberFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function testExceptionOnInvalidParams(): void
}

/**
* @dataProvider provideConstantValues
* @dataProvider provideParseConstantValueCases
*/
public function testParseConstantValue(string $constantName, int $expectedConstant, bool $exceptionExpected): void
{
Expand All @@ -112,21 +112,19 @@ public function testParseConstantValue(string $constantName, int $expectedConsta
}

/**
* @return array<array{string, int, bool}>
* @return iterable<array{string, int, bool}>
*/
public function provideConstantValues(): array
public function provideParseConstantValueCases(): iterable
{
return [
['positive_prefix', \NumberFormatter::POSITIVE_PREFIX, false],
['non_existent_constant', \NumberFormatter::NEGATIVE_PREFIX, true],
];
yield ['positive_prefix', \NumberFormatter::POSITIVE_PREFIX, false];
yield ['non_existent_constant', \NumberFormatter::NEGATIVE_PREFIX, true];
}

/**
* @param array<string, string> $attributes
* @param array<int, string> $expectedAttributes
*
* @dataProvider provideAttributeValues
* @dataProvider provideParseAttributesCases
*/
public function testParseAttributes(array $attributes, array $expectedAttributes, bool $exceptionExpected): void
{
Expand All @@ -143,29 +141,27 @@ public function testParseAttributes(array $attributes, array $expectedAttributes
}

/**
* @return array<array{array<string, string>, array<int, string>, bool}>
* @return iterable<array{array<string, string>, array<int, string>, bool}>
*/
public function provideAttributeValues(): array
public function provideParseAttributesCases(): iterable
{
return [
yield [
[
'positive_prefix' => 'POSITIVE',
'negative_prefix' => 'NEGATIVE',
],
[
[
'positive_prefix' => 'POSITIVE',
'negative_prefix' => 'NEGATIVE',
],
[
\NumberFormatter::POSITIVE_PREFIX => 'POSITIVE',
\NumberFormatter::NEGATIVE_PREFIX => 'NEGATIVE',
],
false,
\NumberFormatter::POSITIVE_PREFIX => 'POSITIVE',
\NumberFormatter::NEGATIVE_PREFIX => 'NEGATIVE',
],
false,
];
yield [
[
[
'non_existent_constant' => 'NON_EXISTENT_VALUE',
],
[],
true,
'non_existent_constant' => 'NON_EXISTENT_VALUE',
],
[],
true,
];
}

Expand Down
18 changes: 8 additions & 10 deletions tests/SonataIntlBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
class SonataIntlBundleTest extends TestCase
{
/**
* @return array<array{string, string, bool, bool}>
* @return iterable<array{string, string, bool, bool}>
*/
public function getVersions(): array
public function provideSymfonyVersionCases(): iterable
{
return [
['2.0.1', '2.0.1', true, true],
['2.0.2', '2.0.1', true, true],
['2.1.1-DEV', '2.1.1', false, true],
['2.1.0-RC1', '2.1.0', false, true],
['2.1.0-RC1', '2.1.1', false, false],
];
yield ['2.0.1', '2.0.1', true, true];
yield ['2.0.2', '2.0.1', true, true];
yield ['2.1.1-DEV', '2.1.1', false, true];
yield ['2.1.0-RC1', '2.1.0', false, true];
yield ['2.1.0-RC1', '2.1.1', false, false];
}

/**
* @dataProvider getVersions
* @dataProvider provideSymfonyVersionCases
*/
public function testSymfonyVersion(string $currentVersion, string $minVersion, bool $versionExpected, bool $versionBundle): void
{
Expand Down
18 changes: 8 additions & 10 deletions tests/Timezone/ChainTimezoneDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@
final class ChainTimezoneDetectorTest extends TestCase
{
/**
* @return array<array{array<string|null>, string}>
* @return iterable<array{array<string|null>, string}>
*/
public static function timezoneProvider(): array
public static function provideDetectsTimezoneForUserCases(): iterable
{
return [
[['Europe/Paris', 'Europe/London'], 'Europe/Paris'],
[['Europe/Paris', null], 'Europe/Paris'],
[[null, 'Europe/Paris'], 'Europe/Paris'],
[[null, null], 'America/Denver'],
[['Invalid/Timezone', null], 'America/Denver'],
];
yield [['Europe/Paris', 'Europe/London'], 'Europe/Paris'];
yield [['Europe/Paris', null], 'Europe/Paris'];
yield [[null, 'Europe/Paris'], 'Europe/Paris'];
yield [[null, null], 'America/Denver'];
yield [['Invalid/Timezone', null], 'America/Denver'];
}

/**
* @param array<string|null> $detectorsTimezones
*
* @dataProvider timezoneProvider
* @dataProvider provideDetectsTimezoneForUserCases
*/
public function testDetectsTimezoneForUser(array $detectorsTimezones, string $expectedTimezone): void
{
Expand Down
10 changes: 4 additions & 6 deletions tests/Timezone/UserBasedTimezoneDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ final class UserBasedTimezoneDetectorTest extends TestCase
/**
* @return iterable<array{string|null}>
*/
public static function timezoneProvider(): iterable
public static function provideUserTimezoneDetectionCases(): iterable
{
return [
['Europe/Paris'],
[null],
];
yield ['Europe/Paris'];
yield [null];
}

/**
* @dataProvider timezoneProvider
* @dataProvider provideUserTimezoneDetectionCases
*/
public function testUserTimezoneDetection(?string $timezone): void
{
Expand Down
Loading

0 comments on commit f5897b5

Please sign in to comment.