From 2930cc7d1e9acb94cf2530a8c537e17a4350d39e Mon Sep 17 00:00:00 2001 From: SonataCI Date: Wed, 27 Sep 2023 16:12:32 +0000 Subject: [PATCH 1/3] DevKit updates --- .php-cs-fixer.dist.php | 2 ++ rector.php | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 72c25056..1afe2e23 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -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, diff --git a/rector.php b/rector.php index 6454e91a..74c4dcde 100644 --- a/rector.php +++ b/rector.php @@ -20,6 +20,9 @@ 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\Set\PHPUnitLevelSetList; +use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -30,6 +33,8 @@ $rectorConfig->sets([ LevelSetList::UP_TO_PHP_80, + PHPUnitLevelSetList::UP_TO_PHPUNIT_90, + PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]); $rectorConfig->importNames(); @@ -37,5 +42,6 @@ $rectorConfig->skip([ CountOnNullRector::class, ExceptionHandlerTypehintRector::class, + AddSeeTestAnnotationRector::class, ]); }; From ab9001b44b1e977876fe2ed8581760b56ee7b4d0 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Thu, 28 Sep 2023 12:12:20 +0000 Subject: [PATCH 2/3] DevKit updates --- rector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rector.php b/rector.php index 74c4dcde..dd4380e3 100644 --- a/rector.php +++ b/rector.php @@ -21,6 +21,7 @@ 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; @@ -43,5 +44,6 @@ CountOnNullRector::class, ExceptionHandlerTypehintRector::class, AddSeeTestAnnotationRector::class, + PreferPHPUnitThisCallRector::class, ]); }; From 89f5340038dc8eb55ecba20c8ef4a12237e7936d Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 3 Oct 2023 10:42:47 +0200 Subject: [PATCH 3/3] Fix --- composer.json | 2 +- tests/Builder/DatagridBuilderTest.php | 20 ++- .../Compiler/AddGuesserCompilerPassTest.php | 30 ++-- .../FilterTypeGuesserTest.php | 94 +++++++------ tests/FieldDescription/TypeGuesserTest.php | 128 +++++++++--------- tests/Filter/BooleanFilterTest.php | 12 +- tests/Filter/DateRangeFilterTest.php | 16 +-- tests/Filter/DateTimeFilterTest.php | 20 ++- tests/Filter/DateTimeRangeFilterTest.php | 16 +-- tests/Filter/IdFilterTest.php | 4 +- tests/Filter/ModelFilterTest.php | 16 +-- tests/Filter/NumberFilterTest.php | 20 ++- tests/Filter/StringFilterTest.php | 14 +- tests/Model/ModelManagerTest.php | 10 +- 14 files changed, 189 insertions(+), 213 deletions(-) diff --git a/composer.json b/composer.json index c15248df..7632463b 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "phpunit/phpunit": "^9.6", "psalm/plugin-phpunit": "^0.18", "psalm/plugin-symfony": "^5.0", - "rector/rector": "^0.17", + "rector/rector": "^0.18", "sonata-project/block-bundle": "^4.2", "symfony/browser-kit": "^5.4 || ^6.2", "symfony/css-selector": "^5.4 || ^6.2", diff --git a/tests/Builder/DatagridBuilderTest.php b/tests/Builder/DatagridBuilderTest.php index cf4511f0..79a9b6b5 100644 --- a/tests/Builder/DatagridBuilderTest.php +++ b/tests/Builder/DatagridBuilderTest.php @@ -80,7 +80,7 @@ protected function setUp(): void /** * @phpstan-param class-string $pager * - * @dataProvider getBaseDatagridData + * @dataProvider provideGetBaseDatagridCases */ public function testGetBaseDatagrid(string $pagerType, string $pager): void { @@ -102,17 +102,15 @@ public function testGetBaseDatagrid(string $pagerType, string $pager): void /** * @phpstan-return iterable */ - public function getBaseDatagridData(): iterable + public function provideGetBaseDatagridCases(): iterable { - return [ - 'simple' => [ - Pager::TYPE_SIMPLE, - SimplePager::class, - ], - 'default' => [ - Pager::TYPE_DEFAULT, - Pager::class, - ], + yield 'simple' => [ + Pager::TYPE_SIMPLE, + SimplePager::class, + ]; + yield 'default' => [ + Pager::TYPE_DEFAULT, + Pager::class, ]; } diff --git a/tests/DependencyInjection/Compiler/AddGuesserCompilerPassTest.php b/tests/DependencyInjection/Compiler/AddGuesserCompilerPassTest.php index 577de245..16727131 100644 --- a/tests/DependencyInjection/Compiler/AddGuesserCompilerPassTest.php +++ b/tests/DependencyInjection/Compiler/AddGuesserCompilerPassTest.php @@ -21,7 +21,7 @@ final class AddGuesserCompilerPassTest extends AbstractCompilerPassTestCase { - /** @dataProvider getBuilders */ + /** @dataProvider provideAddsGuessersCases */ public function testAddsGuessers(string $builderServiceId, string $guesserTag): void { $builderService = new Definition(null, [[]]); @@ -43,23 +43,21 @@ public function testAddsGuessers(string $builderServiceId, string $guesserTag): } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function getBuilders(): array + public function provideAddsGuessersCases(): iterable { - return [ - 'list_builder' => [ - 'sonata.admin.guesser.doctrine_mongodb_list_chain', - 'sonata.admin.guesser.doctrine_mongodb_list', - ], - 'datagrid_builder' => [ - 'sonata.admin.guesser.doctrine_mongodb_datagrid_chain', - 'sonata.admin.guesser.doctrine_mongodb_datagrid', - ], - 'show_builder' => [ - 'sonata.admin.guesser.doctrine_mongodb_show_chain', - 'sonata.admin.guesser.doctrine_mongodb_show', - ], + yield 'list_builder' => [ + 'sonata.admin.guesser.doctrine_mongodb_list_chain', + 'sonata.admin.guesser.doctrine_mongodb_list', + ]; + yield 'datagrid_builder' => [ + 'sonata.admin.guesser.doctrine_mongodb_datagrid_chain', + 'sonata.admin.guesser.doctrine_mongodb_datagrid', + ]; + yield 'show_builder' => [ + 'sonata.admin.guesser.doctrine_mongodb_show_chain', + 'sonata.admin.guesser.doctrine_mongodb_show', ]; } diff --git a/tests/FieldDescription/FilterTypeGuesserTest.php b/tests/FieldDescription/FilterTypeGuesserTest.php index ae26b0a8..82c59f38 100644 --- a/tests/FieldDescription/FilterTypeGuesserTest.php +++ b/tests/FieldDescription/FilterTypeGuesserTest.php @@ -97,7 +97,7 @@ public function testGuessTypeWithAssociation(): void } /** - * @dataProvider noAssociationData + * @dataProvider provideGuessTypeNoAssociationCases */ public function testGuessTypeNoAssociation(string $type, string $resultType, int $confidence, ?string $fieldType = null): void { @@ -131,54 +131,52 @@ public function testGuessTypeNoAssociation(string $type, string $resultType, int * * @phpstan-return iterable */ - public function noAssociationData(): iterable + public function provideGuessTypeNoAssociationCases(): iterable { - return [ - // TODO: Remove it when dropping support of doctrine/mongodb-odm < 3.0 - Type::BOOLEAN => [ - 'boolean', - BooleanFilter::class, - Guess::HIGH_CONFIDENCE, - BooleanType::class, - ], - Type::TIMESTAMP => [ - 'timestamp', - DateTimeFilter::class, - Guess::HIGH_CONFIDENCE, - ], - Type::DATE => [ - 'date', - DateFilter::class, - Guess::HIGH_CONFIDENCE, - ], - Type::FLOAT => [ - 'float', - NumberFilter::class, - Guess::MEDIUM_CONFIDENCE, - NumberType::class, - ], - Type::INT => [ - 'int', - NumberFilter::class, - Guess::MEDIUM_CONFIDENCE, - NumberType::class, - ], - Type::STRING => [ - 'string', - StringFilter::class, - Guess::MEDIUM_CONFIDENCE, - TextType::class, - ], - Type::ID => [ - Type::ID, - IdFilter::class, - Guess::MEDIUM_CONFIDENCE, - ], - 'somefake' => [ - 'somefake', - StringFilter::class, - Guess::LOW_CONFIDENCE, - ], + // TODO: Remove it when dropping support of doctrine/mongodb-odm < 3.0 + yield Type::BOOLEAN => [ + 'boolean', + BooleanFilter::class, + Guess::HIGH_CONFIDENCE, + BooleanType::class, + ]; + yield Type::TIMESTAMP => [ + 'timestamp', + DateTimeFilter::class, + Guess::HIGH_CONFIDENCE, + ]; + yield Type::DATE => [ + 'date', + DateFilter::class, + Guess::HIGH_CONFIDENCE, + ]; + yield Type::FLOAT => [ + 'float', + NumberFilter::class, + Guess::MEDIUM_CONFIDENCE, + NumberType::class, + ]; + yield Type::INT => [ + 'int', + NumberFilter::class, + Guess::MEDIUM_CONFIDENCE, + NumberType::class, + ]; + yield Type::STRING => [ + 'string', + StringFilter::class, + Guess::MEDIUM_CONFIDENCE, + TextType::class, + ]; + yield Type::ID => [ + Type::ID, + IdFilter::class, + Guess::MEDIUM_CONFIDENCE, + ]; + yield 'somefake' => [ + 'somefake', + StringFilter::class, + Guess::LOW_CONFIDENCE, ]; } } diff --git a/tests/FieldDescription/TypeGuesserTest.php b/tests/FieldDescription/TypeGuesserTest.php index dc15420a..fa333fa9 100644 --- a/tests/FieldDescription/TypeGuesserTest.php +++ b/tests/FieldDescription/TypeGuesserTest.php @@ -35,7 +35,7 @@ protected function setUp(): void } /** - * @dataProvider associationData + * @dataProvider provideGuessTypeWithAssociationCases */ public function testGuessTypeWithAssociation(string $mappingType, string $type): void { @@ -59,24 +59,22 @@ public function testGuessTypeWithAssociation(string $mappingType, string $type): } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function associationData(): array + public function provideGuessTypeWithAssociationCases(): iterable { - return [ - 'many-to-one' => [ - ClassMetadata::ONE, - FieldDescriptionInterface::TYPE_MANY_TO_ONE, - ], - 'one-to-many' => [ - ClassMetadata::MANY, - FieldDescriptionInterface::TYPE_MANY_TO_MANY, - ], + yield 'many-to-one' => [ + ClassMetadata::ONE, + FieldDescriptionInterface::TYPE_MANY_TO_ONE, + ]; + yield 'one-to-many' => [ + ClassMetadata::MANY, + FieldDescriptionInterface::TYPE_MANY_TO_MANY, ]; } /** - * @dataProvider noAssociationData + * @dataProvider provideGuessTypeNoAssociationCases */ public function testGuessTypeNoAssociation(string $type, string $resultType, int $confidence): void { @@ -100,61 +98,59 @@ public function testGuessTypeNoAssociation(string $type, string $resultType, int } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function noAssociationData(): array + public function provideGuessTypeNoAssociationCases(): iterable { - return [ - 'collection' => [ - Type::COLLECTION, - FieldDescriptionInterface::TYPE_ARRAY, - Guess::HIGH_CONFIDENCE, - ], - 'hash' => [ - Type::HASH, - FieldDescriptionInterface::TYPE_ARRAY, - Guess::HIGH_CONFIDENCE, - ], - 'bool' => [ - Type::BOOL, - FieldDescriptionInterface::TYPE_BOOLEAN, - Guess::HIGH_CONFIDENCE, - ], - 'timestamp' => [ - Type::TIMESTAMP, - FieldDescriptionInterface::TYPE_DATETIME, - Guess::HIGH_CONFIDENCE, - ], - 'date' => [ - Type::DATE, - FieldDescriptionInterface::TYPE_DATE, - Guess::HIGH_CONFIDENCE, - ], - 'date_immutable' => [ - Type::DATE_IMMUTABLE, - FieldDescriptionInterface::TYPE_DATE, - Guess::HIGH_CONFIDENCE, - ], - 'float' => [ - Type::FLOAT, - FieldDescriptionInterface::TYPE_FLOAT, - Guess::MEDIUM_CONFIDENCE, - ], - 'integer' => [ - Type::INT, - FieldDescriptionInterface::TYPE_INTEGER, - Guess::MEDIUM_CONFIDENCE, - ], - 'string' => [ - Type::STRING, - FieldDescriptionInterface::TYPE_STRING, - Guess::MEDIUM_CONFIDENCE, - ], - 'somefake' => [ - 'somefake', - FieldDescriptionInterface::TYPE_STRING, - Guess::LOW_CONFIDENCE, - ], + yield 'collection' => [ + Type::COLLECTION, + FieldDescriptionInterface::TYPE_ARRAY, + Guess::HIGH_CONFIDENCE, + ]; + yield 'hash' => [ + Type::HASH, + FieldDescriptionInterface::TYPE_ARRAY, + Guess::HIGH_CONFIDENCE, + ]; + yield 'bool' => [ + Type::BOOL, + FieldDescriptionInterface::TYPE_BOOLEAN, + Guess::HIGH_CONFIDENCE, + ]; + yield 'timestamp' => [ + Type::TIMESTAMP, + FieldDescriptionInterface::TYPE_DATETIME, + Guess::HIGH_CONFIDENCE, + ]; + yield 'date' => [ + Type::DATE, + FieldDescriptionInterface::TYPE_DATE, + Guess::HIGH_CONFIDENCE, + ]; + yield 'date_immutable' => [ + Type::DATE_IMMUTABLE, + FieldDescriptionInterface::TYPE_DATE, + Guess::HIGH_CONFIDENCE, + ]; + yield 'float' => [ + Type::FLOAT, + FieldDescriptionInterface::TYPE_FLOAT, + Guess::MEDIUM_CONFIDENCE, + ]; + yield 'integer' => [ + Type::INT, + FieldDescriptionInterface::TYPE_INTEGER, + Guess::MEDIUM_CONFIDENCE, + ]; + yield 'string' => [ + Type::STRING, + FieldDescriptionInterface::TYPE_STRING, + Guess::MEDIUM_CONFIDENCE, + ]; + yield 'somefake' => [ + 'somefake', + FieldDescriptionInterface::TYPE_STRING, + Guess::LOW_CONFIDENCE, ]; } } diff --git a/tests/Filter/BooleanFilterTest.php b/tests/Filter/BooleanFilterTest.php index e8285ce9..e4d822eb 100644 --- a/tests/Filter/BooleanFilterTest.php +++ b/tests/Filter/BooleanFilterTest.php @@ -37,7 +37,7 @@ public function testFilterEmpty(): void } /** - * @dataProvider getScalarValues + * @dataProvider provideFilterScalarCases */ public function testFilterScalar(bool $equalsReturnValue, int $value): void { @@ -57,14 +57,12 @@ public function testFilterScalar(bool $equalsReturnValue, int $value): void } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function getScalarValues(): array + public function provideFilterScalarCases(): iterable { - return [ - [false, BooleanType::TYPE_NO], - [true, BooleanType::TYPE_YES], - ]; + yield [false, BooleanType::TYPE_NO]; + yield [true, BooleanType::TYPE_YES]; } public function testFilterArray(): void diff --git a/tests/Filter/DateRangeFilterTest.php b/tests/Filter/DateRangeFilterTest.php index aa961a91..42387893 100644 --- a/tests/Filter/DateRangeFilterTest.php +++ b/tests/Filter/DateRangeFilterTest.php @@ -22,7 +22,7 @@ final class DateRangeFilterTest extends FilterWithQueryBuilderTest { /** - * @dataProvider getNotApplicableValues + * @dataProvider provideEmptyCases * * @phpstan-param array{start?: mixed, end?: mixed} $value */ @@ -45,13 +45,11 @@ public function testEmpty(array $value): void /** * @phpstan-return iterable> */ - public function getNotApplicableValues(): iterable + public function provideEmptyCases(): iterable { - return [ - [[]], - [['end' => new \DateTime()]], - [['start' => new \DateTime()]], - ]; + yield [[]]; + yield [['end' => new \DateTime()]]; + yield [['start' => new \DateTime()]]; } public function testGetType(): void @@ -116,7 +114,7 @@ public function testFilterEndDate(): void } /** - * @dataProvider provideDates + * @dataProvider provideFilterEndDateCoversWholeDayCases */ public function testFilterEndDateCoversWholeDay( \DateTimeImmutable $expectedEndDateTime, @@ -157,7 +155,7 @@ public function testFilterEndDateCoversWholeDay( /** * @return \Generator */ - public function provideDates(): iterable + public function provideFilterEndDateCoversWholeDayCases(): iterable { yield [ new \DateTimeImmutable('2016-08-31 23:59:59.0-03:00'), diff --git a/tests/Filter/DateTimeFilterTest.php b/tests/Filter/DateTimeFilterTest.php index 3bcc248c..00ca2986 100644 --- a/tests/Filter/DateTimeFilterTest.php +++ b/tests/Filter/DateTimeFilterTest.php @@ -43,7 +43,7 @@ public function testGetType(): void } /** - * @dataProvider getExamples + * @dataProvider provideFilterCases * * @phpstan-param array{type?: int, value?: \DateTime} $data */ @@ -65,18 +65,16 @@ public function testFilter(array $data, string $method): void } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function getExamples(): array + public function provideFilterCases(): iterable { - return [ - [['type' => DateOperatorType::TYPE_EQUAL, 'value' => new \DateTime('now')], 'equals'], - [['type' => DateOperatorType::TYPE_GREATER_EQUAL, 'value' => new \DateTime('now')], 'gte'], - [['type' => DateOperatorType::TYPE_GREATER_THAN, 'value' => new \DateTime('now')], 'gt'], - [['type' => DateOperatorType::TYPE_LESS_EQUAL, 'value' => new \DateTime('now')], 'lte'], - [['type' => DateOperatorType::TYPE_LESS_THAN, 'value' => new \DateTime('now')], 'lt'], - [['value' => new \DateTime('now')], 'equals'], - ]; + yield [['type' => DateOperatorType::TYPE_EQUAL, 'value' => new \DateTime('now')], 'equals']; + yield [['type' => DateOperatorType::TYPE_GREATER_EQUAL, 'value' => new \DateTime('now')], 'gte']; + yield [['type' => DateOperatorType::TYPE_GREATER_THAN, 'value' => new \DateTime('now')], 'gt']; + yield [['type' => DateOperatorType::TYPE_LESS_EQUAL, 'value' => new \DateTime('now')], 'lte']; + yield [['type' => DateOperatorType::TYPE_LESS_THAN, 'value' => new \DateTime('now')], 'lt']; + yield [['value' => new \DateTime('now')], 'equals']; } private function createFilter(): DateTimeFilter diff --git a/tests/Filter/DateTimeRangeFilterTest.php b/tests/Filter/DateTimeRangeFilterTest.php index 125665af..0800d49b 100644 --- a/tests/Filter/DateTimeRangeFilterTest.php +++ b/tests/Filter/DateTimeRangeFilterTest.php @@ -22,7 +22,7 @@ final class DateTimeRangeFilterTest extends FilterWithQueryBuilderTest { /** - * @dataProvider getNotApplicableValues + * @dataProvider provideEmptyCases * * @phpstan-param array{start?: mixed, end?: mixed} $value */ @@ -45,13 +45,11 @@ public function testEmpty(array $value): void /** * @phpstan-return iterable> */ - public function getNotApplicableValues(): iterable + public function provideEmptyCases(): iterable { - return [ - [[]], - [['end' => new \DateTime()]], - [['start' => new \DateTime()]], - ]; + yield [[]]; + yield [['end' => new \DateTime()]]; + yield [['start' => new \DateTime()]]; } public function testGetType(): void @@ -60,7 +58,7 @@ public function testGetType(): void } /** - * @dataProvider getBetweenTypes + * @dataProvider provideFilterBetweenCases */ public function testFilterBetween(?int $type): void { @@ -96,7 +94,7 @@ public function testFilterBetween(?int $type): void /** * @phpstan-return iterable */ - public function getBetweenTypes(): iterable + public function provideFilterBetweenCases(): iterable { yield 'default' => [null]; yield 'between' => [DateRangeOperatorType::TYPE_BETWEEN]; diff --git a/tests/Filter/IdFilterTest.php b/tests/Filter/IdFilterTest.php index 30246586..3b4d1b35 100644 --- a/tests/Filter/IdFilterTest.php +++ b/tests/Filter/IdFilterTest.php @@ -56,7 +56,7 @@ public function testItDoesNotApplyWithWrongObjectId(): void } /** - * @dataProvider getEqualTypes + * @dataProvider provideDefaultTypeIsEqualsCases */ public function testDefaultTypeIsEquals(?int $type): void { @@ -81,7 +81,7 @@ public function testDefaultTypeIsEquals(?int $type): void /** * @phpstan-return iterable */ - public function getEqualTypes(): iterable + public function provideDefaultTypeIsEqualsCases(): iterable { yield 'default type' => [null]; yield 'equals type' => [EqualOperatorType::TYPE_EQUAL]; diff --git a/tests/Filter/ModelFilterTest.php b/tests/Filter/ModelFilterTest.php index 90974772..fa3b573a 100644 --- a/tests/Filter/ModelFilterTest.php +++ b/tests/Filter/ModelFilterTest.php @@ -240,7 +240,7 @@ public function testAssociationWithValidParentAssociationMappings(): void } /** - * @dataProvider getMappings + * @dataProvider provideDifferentIdentifiersBasedOnMappingCases */ public function testDifferentIdentifiersBasedOnMapping(string $storeAs, string $fieldIdentifier): void { @@ -269,16 +269,14 @@ public function testDifferentIdentifiersBasedOnMapping(string $storeAs, string $ } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function getMappings(): array + public function provideDifferentIdentifiersBasedOnMappingCases(): iterable { - return [ - [ClassMetadata::REFERENCE_STORE_AS_REF, '.id'], - [ClassMetadata::REFERENCE_STORE_AS_ID, ''], - [ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB, '.$id'], - [ClassMetadata::REFERENCE_STORE_AS_DB_REF, '.$id'], - ]; + yield [ClassMetadata::REFERENCE_STORE_AS_REF, '.id']; + yield [ClassMetadata::REFERENCE_STORE_AS_ID, '']; + yield [ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB, '.$id']; + yield [ClassMetadata::REFERENCE_STORE_AS_DB_REF, '.$id']; } public function testDefaultValues(): void diff --git a/tests/Filter/NumberFilterTest.php b/tests/Filter/NumberFilterTest.php index f00eeb53..1add81f4 100644 --- a/tests/Filter/NumberFilterTest.php +++ b/tests/Filter/NumberFilterTest.php @@ -53,7 +53,7 @@ public function testFilterInvalidOperator(): void } /** - * @dataProvider getNumberExamples + * @dataProvider provideFilterCases * * @phpstan-param array{type?: int, value: int} $data */ @@ -74,18 +74,16 @@ public function testFilter(array $data, string $method): void } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function getNumberExamples(): array + public function provideFilterCases(): iterable { - return [ - [['type' => NumberOperatorType::TYPE_EQUAL, 'value' => 42], 'equals'], - [['type' => NumberOperatorType::TYPE_GREATER_EQUAL, 'value' => 42], 'gte'], - [['type' => NumberOperatorType::TYPE_GREATER_THAN, 'value' => 42], 'gt'], - [['type' => NumberOperatorType::TYPE_LESS_EQUAL, 'value' => 42], 'lte'], - [['type' => NumberOperatorType::TYPE_LESS_THAN, 'value' => 42], 'lt'], - [['value' => 42], 'equals'], - ]; + yield [['type' => NumberOperatorType::TYPE_EQUAL, 'value' => 42], 'equals']; + yield [['type' => NumberOperatorType::TYPE_GREATER_EQUAL, 'value' => 42], 'gte']; + yield [['type' => NumberOperatorType::TYPE_GREATER_THAN, 'value' => 42], 'gt']; + yield [['type' => NumberOperatorType::TYPE_LESS_EQUAL, 'value' => 42], 'lte']; + yield [['type' => NumberOperatorType::TYPE_LESS_THAN, 'value' => 42], 'lt']; + yield [['value' => 42], 'equals']; } public function testDefaultValues(): void diff --git a/tests/Filter/StringFilterTest.php b/tests/Filter/StringFilterTest.php index 62a8fdaa..f5922a13 100644 --- a/tests/Filter/StringFilterTest.php +++ b/tests/Filter/StringFilterTest.php @@ -76,7 +76,7 @@ public function testDefaultTypeIsContains(): void } /** - * @dataProvider getContainsTypes + * @dataProvider provideContainsCases */ public function testContains(string $method, int $type, mixed $value): void { @@ -99,15 +99,13 @@ public function testContains(string $method, int $type, mixed $value): void } /** - * @phpstan-return array + * @phpstan-return iterable */ - public function getContainsTypes(): array + public function provideContainsCases(): iterable { - return [ - ['equals', ContainsOperatorType::TYPE_CONTAINS, new Regex('asd', 'i')], - ['equals', ContainsOperatorType::TYPE_EQUAL, 'asd'], - ['not', ContainsOperatorType::TYPE_NOT_CONTAINS, new Regex('asd', 'i')], - ]; + yield ['equals', ContainsOperatorType::TYPE_CONTAINS, new Regex('asd', 'i')]; + yield ['equals', ContainsOperatorType::TYPE_EQUAL, 'asd']; + yield ['not', ContainsOperatorType::TYPE_NOT_CONTAINS, new Regex('asd', 'i')]; } public function testNotContains(): void diff --git a/tests/Model/ModelManagerTest.php b/tests/Model/ModelManagerTest.php index f833bb12..2350fd3a 100644 --- a/tests/Model/ModelManagerTest.php +++ b/tests/Model/ModelManagerTest.php @@ -49,7 +49,7 @@ final class ModelManagerTest extends TestCase /** * @var Stub&ManagerRegistry */ - private $registry; + private Stub $registry; protected function setUp(): void { @@ -150,7 +150,7 @@ public function testCreateQuery(): void } /** - * @dataProvider supportsQueryDataProvider + * @dataProvider provideSupportsQueryCases */ public function testSupportsQuery(bool $expected, object $object): void { @@ -202,7 +202,7 @@ public function testGetRealClassWithNonProxyObject(): void /** * @phpstan-return iterable */ - public function supportsQueryDataProvider(): iterable + public function provideSupportsQueryCases(): iterable { yield [true, new ProxyQuery($this->createStub(Builder::class))]; yield [true, $this->createStub(Builder::class)]; @@ -214,7 +214,7 @@ public function supportsQueryDataProvider(): iterable * * @phpstan-return iterable, 2: array}> */ - public function failingBatchDeleteProvider(): iterable + public function provideFailingBatchDeleteCases(): iterable { yield [ '#^Failed to delete object "Sonata\\\DoctrineMongoDBAdminBundle\\\Tests\\\Fixtures\\\Document\\\DocumentWithReferences"' @@ -242,7 +242,7 @@ public function failingBatchDeleteProvider(): iterable * @param array $result * @param array $onConsecutiveFlush * - * @dataProvider failingBatchDeleteProvider + * @dataProvider provideFailingBatchDeleteCases */ public function testFailingBatchDelete(string $expectedExceptionMessage, array $result, array $onConsecutiveFlush): void {