Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and github-actions[bot] committed Oct 3, 2023
1 parent ab604bf commit 51bf0d1
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 146 deletions.
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
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

0 comments on commit 51bf0d1

Please sign in to comment.