From 5e645640a3620455618f6562e10434e0e1b9bb0e Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sun, 29 Oct 2023 08:36:22 +0100 Subject: [PATCH] Use PHPUnit attributes instead of annotations --- phpstan-baseline.neon | 4 +- .../MongoDB/Tests/Aggregation/ExprTest.php | 75 +++++---- .../Aggregation/Stage/BucketAutoTest.php | 4 +- .../Tests/Aggregation/Stage/BucketTest.php | 4 +- .../Tests/Aggregation/Stage/GeoNearTest.php | 8 +- .../Aggregation/Stage/GraphLookupTest.php | 7 +- .../Tests/Aggregation/Stage/GroupTest.php | 4 +- .../Tests/Aggregation/Stage/MergeTest.php | 8 +- .../Tests/Aggregation/Stage/OperatorTest.php | 32 ++-- .../Tests/Aggregation/Stage/ProjectTest.php | 3 +- .../Tests/Aggregation/Stage/SearchTest.php | 95 +++++------ .../Aggregation/Stage/SetWindowFieldsTest.php | 7 +- .../Tests/Aggregation/Stage/SortTest.php | 7 +- .../ODM/MongoDB/Tests/DocumentManagerTest.php | 5 +- .../Tests/Functional/AtomicSetTest.php | 8 +- .../MongoDB/Tests/Functional/BinDataTest.php | 3 +- .../ODM/MongoDB/Tests/Functional/DateTest.php | 4 +- .../Functional/DocumentPersisterTest.php | 55 ++----- .../Tests/Functional/EnsureShardingTest.php | 3 +- .../Tests/Functional/FunctionalTest.php | 8 +- .../ODM/MongoDB/Tests/Functional/IdTest.php | 13 +- .../ODM/MongoDB/Tests/Functional/LockTest.php | 3 +- .../Tests/Functional/MemoryUsageTest.php | 7 +- .../Functional/NestedCollectionsTest.php | 3 +- .../MongoDB/Tests/Functional/QueryTest.php | 6 +- .../MongoDB/Tests/Functional/RawTypeTest.php | 8 +- .../Tests/Functional/ReadPreferenceTest.php | 8 +- .../Tests/Functional/ReferencePrimerTest.php | 3 +- .../MongoDB/Tests/Functional/ShardKeyTest.php | 3 +- .../SplObjectHashCollisionsTest.php | 15 +- .../Tests/Functional/TestTargetDocument.php | 3 +- .../Tests/Functional/Ticket/GH1058Test.php | 5 +- .../Tests/Functional/Ticket/GH1229Test.php | 5 +- .../Tests/Functional/Ticket/GH1232Test.php | 3 +- .../Tests/Functional/Ticket/GH1275Test.php | 3 +- .../Tests/Functional/Ticket/GH1346Test.php | 3 +- .../Tests/Functional/Ticket/GH1428Test.php | 3 +- .../Tests/Functional/Ticket/GH2002Test.php | 10 +- .../Tests/Functional/Ticket/GH2251Test.php | 6 +- .../Tests/Functional/Ticket/GH560Test.php | 22 +-- .../Tests/Functional/Ticket/GH852Test.php | 3 +- .../Tests/Functional/Ticket/MODM160Test.php | 7 +- .../AbstractAnnotationDriverTestCase.php | 3 +- .../Mapping/AbstractMappingDriverTestCase.php | 94 ++++------- .../Tests/Mapping/ClassMetadataTest.php | 22 +-- .../Symfony/AbstractDriverTestCase.php | 3 +- .../Tests/Mapping/Symfony/XmlDriverTest.php | 3 +- .../Performance/HydrationPerformanceTest.php | 7 +- .../Performance/InsertPerformanceTest.php | 7 +- .../Tests/Performance/MemoryUsageTest.php | 7 +- .../Performance/UnitOfWorkPerformanceTest.php | 7 +- .../Tests/PersistentCollectionTest.php | 7 +- .../Persisters/PersistenceBuilderTest.php | 8 +- .../ODM/MongoDB/Tests/Query/BuilderTest.php | 40 ++--- .../Tests/Query/CriteriaMergerTest.php | 4 +- .../ODM/MongoDB/Tests/Query/ExprTest.php | 13 +- .../Tests/Query/FilterCollectionTest.php | 3 +- .../Query/QueryExpressionVisitorTest.php | 8 +- .../Doctrine/ODM/MongoDB/Tests/QueryTest.php | 8 +- .../ODM/MongoDB/Tests/SchemaManagerTest.php | 154 +++++------------- .../Tests/Types/DateImmutableTypeTest.php | 22 +-- .../ODM/MongoDB/Tests/Types/DateTypeTest.php | 22 +-- .../ODM/MongoDB/Tests/Types/IdTypeTest.php | 8 +- .../ODM/MongoDB/Tests/Types/TypeTest.php | 15 +- .../ODM/MongoDB/Tests/UnitOfWorkTest.php | 7 +- 65 files changed, 387 insertions(+), 571 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1af5384a74..c965754ae5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -981,12 +981,12 @@ parameters: path: tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataLoadEventTest.php - - message: "#^Parameter \\#1 \\$mapping of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\\\:\\:mapField\\(\\) expects array\\{type\\?\\: string, fieldName\\?\\: string, name\\?\\: string, strategy\\?\\: string, association\\?\\: int, id\\?\\: bool, isOwningSide\\?\\: bool, collectionClass\\?\\: class\\-string, \\.\\.\\.\\}, array\\{fieldName\\: 'enum', enumType\\: 'Documents\\\\\\\\Card'\\} given\\.$#" + message: "#^Parameter \\#1 \\$mapping of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\\\:\\:mapField\\(\\) expects array\\{type\\?\\: string, fieldName\\?\\: string, name\\?\\: string, strategy\\?\\: string, association\\?\\: int, id\\?\\: bool, isOwningSide\\?\\: bool, collectionClass\\?\\: class\\-string, \\.\\.\\.\\}, array\\{fieldName\\: 'enum', enumType\\: 'Documents\\\\\\\\Card'\\} given\\.$#" count: 1 path: tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php - - message: "#^Parameter \\#1 \\$mapping of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\\\:\\:mapField\\(\\) expects array\\{type\\?\\: string, fieldName\\?\\: string, name\\?\\: string, strategy\\?\\: string, association\\?\\: int, id\\?\\: bool, isOwningSide\\?\\: bool, collectionClass\\?\\: class\\-string, \\.\\.\\.\\}, array\\{fieldName\\: 'enum', enumType\\: 'Documents\\\\\\\\SuitNonBacked'\\} given\\.$#" + message: "#^Parameter \\#1 \\$mapping of method Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\\\:\\:mapField\\(\\) expects array\\{type\\?\\: string, fieldName\\?\\: string, name\\?\\: string, strategy\\?\\: string, association\\?\\: int, id\\?\\: bool, isOwningSide\\?\\: bool, collectionClass\\?\\: class\\-string, \\.\\.\\.\\}, array\\{fieldName\\: 'enum', enumType\\: 'Documents\\\\\\\\SuitNonBacked'\\} given\\.$#" count: 1 path: tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php index f101652d09..6fa635badd 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php @@ -9,6 +9,7 @@ use Doctrine\ODM\MongoDB\Aggregation\Expr; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use LogicException; +use PHPUnit\Framework\Attributes\DataProvider; class ExprTest extends BaseTestCase { @@ -17,26 +18,25 @@ class ExprTest extends BaseTestCase /** * @param array $expected * @param Closure(Expr): mixed[]|mixed[] $args - * - * @dataProvider provideAccumulatorExpressionOperators - * @dataProvider provideArithmeticExpressionOperators - * @dataProvider provideArrayExpressionOperators - * @dataProvider provideBooleanExpressionOperators - * @dataProvider provideComparisonExpressionOperators - * @dataProvider provideConditionalExpressionOperators - * @dataProvider provideCustomExpressionOperators - * @dataProvider provideDataSizeExpressionOperators - * @dataProvider provideDateExpressionOperators - * @dataProvider provideGroupAccumulatorExpressionOperators - * @dataProvider provideMiscExpressionOperators - * @dataProvider provideObjectExpressionOperators - * @dataProvider provideSetExpressionOperators - * @dataProvider provideStringExpressionOperators - * @dataProvider provideTimestampExpressionOperators - * @dataProvider provideTrigonometryExpressionOperators - * @dataProvider provideTypeExpressionOperators - * @dataProvider provideWindowExpressionOperators */ + #[DataProvider('provideAccumulatorExpressionOperators')] + #[DataProvider('provideArithmeticExpressionOperators')] + #[DataProvider('provideArrayExpressionOperators')] + #[DataProvider('provideBooleanExpressionOperators')] + #[DataProvider('provideComparisonExpressionOperators')] + #[DataProvider('provideConditionalExpressionOperators')] + #[DataProvider('provideCustomExpressionOperators')] + #[DataProvider('provideDataSizeExpressionOperators')] + #[DataProvider('provideDateExpressionOperators')] + #[DataProvider('provideGroupAccumulatorExpressionOperators')] + #[DataProvider('provideMiscExpressionOperators')] + #[DataProvider('provideObjectExpressionOperators')] + #[DataProvider('provideSetExpressionOperators')] + #[DataProvider('provideStringExpressionOperators')] + #[DataProvider('provideTimestampExpressionOperators')] + #[DataProvider('provideTrigonometryExpressionOperators')] + #[DataProvider('provideTypeExpressionOperators')] + #[DataProvider('provideWindowExpressionOperators')] public function testGenericOperator(array $expected, string $operator, $args): void { $expr = $this->createExpr(); @@ -49,26 +49,25 @@ public function testGenericOperator(array $expected, string $operator, $args): v /** * @param array $expected * @param Closure(Expr): mixed[]|mixed[] $args - * - * @dataProvider provideAccumulatorExpressionOperators - * @dataProvider provideArithmeticExpressionOperators - * @dataProvider provideArrayExpressionOperators - * @dataProvider provideBooleanExpressionOperators - * @dataProvider provideComparisonExpressionOperators - * @dataProvider provideConditionalExpressionOperators - * @dataProvider provideCustomExpressionOperators - * @dataProvider provideDataSizeExpressionOperators - * @dataProvider provideDateExpressionOperators - * @dataProvider provideGroupAccumulatorExpressionOperators - * @dataProvider provideMiscExpressionOperators - * @dataProvider provideObjectExpressionOperators - * @dataProvider provideSetExpressionOperators - * @dataProvider provideStringExpressionOperators - * @dataProvider provideTimestampExpressionOperators - * @dataProvider provideTrigonometryExpressionOperators - * @dataProvider provideTypeExpressionOperators - * @dataProvider provideWindowExpressionOperators */ + #[DataProvider('provideAccumulatorExpressionOperators')] + #[DataProvider('provideArithmeticExpressionOperators')] + #[DataProvider('provideArrayExpressionOperators')] + #[DataProvider('provideBooleanExpressionOperators')] + #[DataProvider('provideComparisonExpressionOperators')] + #[DataProvider('provideConditionalExpressionOperators')] + #[DataProvider('provideCustomExpressionOperators')] + #[DataProvider('provideDataSizeExpressionOperators')] + #[DataProvider('provideDateExpressionOperators')] + #[DataProvider('provideGroupAccumulatorExpressionOperators')] + #[DataProvider('provideMiscExpressionOperators')] + #[DataProvider('provideObjectExpressionOperators')] + #[DataProvider('provideSetExpressionOperators')] + #[DataProvider('provideStringExpressionOperators')] + #[DataProvider('provideTimestampExpressionOperators')] + #[DataProvider('provideTrigonometryExpressionOperators')] + #[DataProvider('provideTypeExpressionOperators')] + #[DataProvider('provideWindowExpressionOperators')] public function testGenericOperatorWithField(array $expected, string $operator, $args): void { $expr = $this->createExpr(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketAutoTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketAutoTest.php index d390c81d86..fbf56fc136 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketAutoTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketAutoTest.php @@ -13,6 +13,7 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsComment; use Documents\User; +use PHPUnit\Framework\Attributes\DataProvider; class BucketAutoTest extends BaseTestCase { @@ -22,9 +23,8 @@ class BucketAutoTest extends BaseTestCase /** * @param array $expected * @param mixed[]|Closure(Expr): mixed[] $args - * - * @dataProvider provideGroupAccumulatorExpressionOperators */ + #[DataProvider('provideGroupAccumulatorExpressionOperators')] public function testGroupAccumulators(array $expected, string $operator, $args): void { $args = $this->resolveArgs($args); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketTest.php index 476c540c2d..2bba512750 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/BucketTest.php @@ -13,6 +13,7 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsComment; use Documents\User; +use PHPUnit\Framework\Attributes\DataProvider; class BucketTest extends BaseTestCase { @@ -22,9 +23,8 @@ class BucketTest extends BaseTestCase /** * @param array $expected * @param mixed[]|Closure(Expr): mixed[] $args - * - * @dataProvider provideGroupAccumulatorExpressionOperators */ + #[DataProvider('provideGroupAccumulatorExpressionOperators')] public function testGroupAccumulators(array $expected, string $operator, $args): void { $args = $this->resolveArgs($args); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php index 5c7cb58dca..687ff1a5de 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GeoNearTest.php @@ -7,6 +7,7 @@ use Doctrine\ODM\MongoDB\Aggregation\Stage\GeoNear; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationTestTrait; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class GeoNearTest extends BaseTestCase { @@ -37,11 +38,8 @@ public function testFromBuilder(): void self::assertSame([['$geoNear' => $stage]], $builder->getPipeline()); } - /** - * @param mixed $value - * - * @dataProvider provideOptionalSettings - */ + /** @param mixed $value */ + #[DataProvider('provideOptionalSettings')] public function testOptionalSettings(string $field, $value): void { $geoNearStage = new GeoNear($this->getTestAggregationBuilder(), 0, 0); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GraphLookupTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GraphLookupTest.php index ed9f3d2157..21489a8ddf 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GraphLookupTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GraphLookupTest.php @@ -16,6 +16,7 @@ use Documents\GraphLookup\ReportingHierarchy; use Documents\GraphLookup\Traveller; use Documents\User; +use PHPUnit\Framework\Attributes\DataProvider; use function array_merge; use function count; @@ -149,9 +150,8 @@ public static function provideEmployeeAggregations(): array /** * @param Closure(Builder): GraphLookup $addGraphLookupStage * @param array $expectedFields - * - * @dataProvider provideEmployeeAggregations */ + #[DataProvider('provideEmployeeAggregations')] public function testWithEmployees(Closure $addGraphLookupStage, array $expectedFields): void { $this->insertEmployeeTestData(); @@ -222,9 +222,8 @@ public static function provideTravellerAggregations(): array /** * @param Closure(Builder): GraphLookup $addGraphLookupStage * @param array $expectedFields - * - * @dataProvider provideTravellerAggregations */ + #[DataProvider('provideTravellerAggregations')] public function testWithTraveller(Closure $addGraphLookupStage, array $expectedFields): void { $this->insertTravellerTestData(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php index 539b0886dc..bd2c5f40fb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/GroupTest.php @@ -10,6 +10,7 @@ use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationOperatorsProviderTrait; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationTestTrait; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class GroupTest extends BaseTestCase { @@ -19,9 +20,8 @@ class GroupTest extends BaseTestCase /** * @param array $expected * @param mixed[]|Closure(Expr): mixed[] $args - * - * @dataProvider provideGroupAccumulatorExpressionOperators */ + #[DataProvider('provideGroupAccumulatorExpressionOperators')] public function testGroupAccumulators(array $expected, string $operator, $args): void { $groupStage = new Group($this->getTestAggregationBuilder()); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MergeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MergeTest.php index 638f0c195b..1875b6b4b8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MergeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/MergeTest.php @@ -10,6 +10,7 @@ use Documents\User; use Generator; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use function is_callable; @@ -80,11 +81,8 @@ public static function providePipeline(): Generator ]; } - /** - * @param array>|callable $pipeline - * - * @dataProvider providePipeline - */ + /** @param array>|callable $pipeline */ + #[DataProvider('providePipeline')] public function testStageWithPipeline($pipeline): void { if (is_callable($pipeline)) { diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php index 86874e6958..f5c33dfb3c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php @@ -11,6 +11,7 @@ use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationOperatorsProviderTrait; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationTestTrait; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class OperatorTest extends BaseTestCase { @@ -20,23 +21,22 @@ class OperatorTest extends BaseTestCase /** * @param array $expected * @param mixed[]|Closure(Expr): mixed[] $args - * - * @dataProvider provideAccumulatorExpressionOperators - * @dataProvider provideArithmeticExpressionOperators - * @dataProvider provideArrayExpressionOperators - * @dataProvider provideBooleanExpressionOperators - * @dataProvider provideComparisonExpressionOperators - * @dataProvider provideConditionalExpressionOperators - * @dataProvider provideDataSizeExpressionOperators - * @dataProvider provideDateExpressionOperators - * @dataProvider provideMiscExpressionOperators - * @dataProvider provideObjectExpressionOperators - * @dataProvider provideSetExpressionOperators - * @dataProvider provideStringExpressionOperators - * @dataProvider provideTimestampExpressionOperators - * @dataProvider provideTrigonometryExpressionOperators - * @dataProvider provideTypeExpressionOperators */ + #[DataProvider('provideAccumulatorExpressionOperators')] + #[DataProvider('provideArithmeticExpressionOperators')] + #[DataProvider('provideArrayExpressionOperators')] + #[DataProvider('provideBooleanExpressionOperators')] + #[DataProvider('provideComparisonExpressionOperators')] + #[DataProvider('provideConditionalExpressionOperators')] + #[DataProvider('provideDataSizeExpressionOperators')] + #[DataProvider('provideDateExpressionOperators')] + #[DataProvider('provideMiscExpressionOperators')] + #[DataProvider('provideObjectExpressionOperators')] + #[DataProvider('provideSetExpressionOperators')] + #[DataProvider('provideStringExpressionOperators')] + #[DataProvider('provideTimestampExpressionOperators')] + #[DataProvider('provideTrigonometryExpressionOperators')] + #[DataProvider('provideTypeExpressionOperators')] public function testProxiedExpressionOperators(array $expected, string $operator, $args): void { $stage = $this->getStubStage(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php index 376f48a19b..5511d1ee11 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/ProjectTest.php @@ -8,6 +8,7 @@ use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationOperatorsProviderTrait; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationTestTrait; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ProjectTest extends BaseTestCase { @@ -39,7 +40,7 @@ public function testFromBuilder(): void self::assertSame([['$project' => ['_id' => false, '$field' => true, '$otherField' => true, 'product' => ['$multiply' => ['$field', 5]]]]], $builder->getPipeline()); } - /** @dataProvider provideAccumulatorExpressionOperators */ + #[DataProvider('provideAccumulatorExpressionOperators')] public function testAccumulatorsWithMultipleArguments(array $expected, string $operator, $args): void { $projectStage = new Project($this->getTestAggregationBuilder()); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SearchTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SearchTest.php index 5903cfa2ef..4d35bb93de 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SearchTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SearchTest.php @@ -14,6 +14,7 @@ use GeoJson\Geometry\Point; use GeoJson\Geometry\Polygon; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Constraint\IsInstanceOf; use function array_combine; @@ -1126,24 +1127,22 @@ public static function provideWildcardBuilders(): Generator ]; } - /** - * @dataProvider provideAutocompleteBuilders - * @dataProvider provideCompoundBuilders - * @dataProvider provideEmbeddedDocumentBuilders - * @dataProvider provideEmbeddedDocumentCompoundBuilders - * @dataProvider provideEqualsBuilders - * @dataProvider provideExistsBuilders - * @dataProvider provideGeoShapeBuilders - * @dataProvider provideGeoWithinBuilders - * @dataProvider provideMoreLikeThisBuilders - * @dataProvider provideNearBuilders - * @dataProvider providePhraseBuilders - * @dataProvider provideQueryStringBuilders - * @dataProvider provideRangeBuilders - * @dataProvider provideRegexBuilders - * @dataProvider provideTextBuilders - * @dataProvider provideWildcardBuilders - */ + #[DataProvider('provideAutocompleteBuilders')] + #[DataProvider('provideCompoundBuilders')] + #[DataProvider('provideEmbeddedDocumentBuilders')] + #[DataProvider('provideEmbeddedDocumentCompoundBuilders')] + #[DataProvider('provideEqualsBuilders')] + #[DataProvider('provideExistsBuilders')] + #[DataProvider('provideGeoShapeBuilders')] + #[DataProvider('provideGeoWithinBuilders')] + #[DataProvider('provideMoreLikeThisBuilders')] + #[DataProvider('provideNearBuilders')] + #[DataProvider('providePhraseBuilders')] + #[DataProvider('provideQueryStringBuilders')] + #[DataProvider('provideRangeBuilders')] + #[DataProvider('provideRegexBuilders')] + #[DataProvider('provideTextBuilders')] + #[DataProvider('provideWildcardBuilders')] public function testSearchOperators(array $expectedOperator, Closure $createOperator): void { $baseExpected = [ @@ -1182,22 +1181,20 @@ public function testSearchOperators(array $expectedOperator, Closure $createOper ); } - /** - * @dataProvider provideAutocompleteBuilders - * @dataProvider provideEmbeddedDocumentBuilders - * @dataProvider provideEqualsBuilders - * @dataProvider provideExistsBuilders - * @dataProvider provideGeoShapeBuilders - * @dataProvider provideGeoWithinBuilders - * @dataProvider provideMoreLikeThisBuilders - * @dataProvider provideNearBuilders - * @dataProvider providePhraseBuilders - * @dataProvider provideQueryStringBuilders - * @dataProvider provideRangeBuilders - * @dataProvider provideRegexBuilders - * @dataProvider provideTextBuilders - * @dataProvider provideWildcardBuilders - */ + #[DataProvider('provideAutocompleteBuilders')] + #[DataProvider('provideEmbeddedDocumentBuilders')] + #[DataProvider('provideEqualsBuilders')] + #[DataProvider('provideExistsBuilders')] + #[DataProvider('provideGeoShapeBuilders')] + #[DataProvider('provideGeoWithinBuilders')] + #[DataProvider('provideMoreLikeThisBuilders')] + #[DataProvider('provideNearBuilders')] + #[DataProvider('providePhraseBuilders')] + #[DataProvider('provideQueryStringBuilders')] + #[DataProvider('provideRangeBuilders')] + #[DataProvider('provideRegexBuilders')] + #[DataProvider('provideTextBuilders')] + #[DataProvider('provideWildcardBuilders')] public function testSearchCompoundOperators(array $expectedOperator, Closure $createOperator): void { $searchStage = new Search($this->getTestAggregationBuilder()); @@ -1233,22 +1230,20 @@ public function testSearchCompoundOperators(array $expectedOperator, Closure $cr ); } - /** - * @dataProvider provideAutocompleteBuilders - * @dataProvider provideCompoundBuilders - * @dataProvider provideEqualsBuilders - * @dataProvider provideExistsBuilders - * @dataProvider provideGeoShapeBuilders - * @dataProvider provideGeoWithinBuilders - * @dataProvider provideMoreLikeThisBuilders - * @dataProvider provideNearBuilders - * @dataProvider providePhraseBuilders - * @dataProvider provideQueryStringBuilders - * @dataProvider provideRangeBuilders - * @dataProvider provideRegexBuilders - * @dataProvider provideTextBuilders - * @dataProvider provideWildcardBuilders - */ + #[DataProvider('provideAutocompleteBuilders')] + #[DataProvider('provideCompoundBuilders')] + #[DataProvider('provideEqualsBuilders')] + #[DataProvider('provideExistsBuilders')] + #[DataProvider('provideGeoShapeBuilders')] + #[DataProvider('provideGeoWithinBuilders')] + #[DataProvider('provideMoreLikeThisBuilders')] + #[DataProvider('provideNearBuilders')] + #[DataProvider('providePhraseBuilders')] + #[DataProvider('provideQueryStringBuilders')] + #[DataProvider('provideRangeBuilders')] + #[DataProvider('provideRegexBuilders')] + #[DataProvider('provideTextBuilders')] + #[DataProvider('provideWildcardBuilders')] public function testSearchEmbeddedDocumentOperators(array $expectedOperator, Closure $createOperator): void { $searchStage = new Search($this->getTestAggregationBuilder()); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SetWindowFieldsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SetWindowFieldsTest.php index 152afc78b6..9739aac775 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SetWindowFieldsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SetWindowFieldsTest.php @@ -8,6 +8,7 @@ use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationOperatorsProviderTrait; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationTestTrait; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; use function array_merge; @@ -73,10 +74,8 @@ public function testStage(): void ); } - /** - * @dataProvider provideGroupAccumulatorExpressionOperators - * @dataProvider provideWindowExpressionOperators - */ + #[DataProvider('provideGroupAccumulatorExpressionOperators')] + #[DataProvider('provideWindowExpressionOperators')] public function testOperators(array $expected, string $operator, $args): void { $args = $this->resolveArgs($args); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php index 2c11c88a97..76331a095c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/SortTest.php @@ -7,6 +7,7 @@ use Doctrine\ODM\MongoDB\Aggregation\Stage\Sort; use Doctrine\ODM\MongoDB\Tests\Aggregation\AggregationTestTrait; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** @psalm-import-type SortShape from Sort */ class SortTest extends BaseTestCase @@ -16,9 +17,8 @@ class SortTest extends BaseTestCase /** * @param string|array $field * @psalm-param SortShape $expectedSort - * - * @dataProvider provideSortOptions */ + #[DataProvider('provideSortOptions')] public function testStage(array $expectedSort, $field, ?string $order = null): void { $sortStage = new Sort($this->getTestAggregationBuilder(), $field, $order); @@ -29,9 +29,8 @@ public function testStage(array $expectedSort, $field, ?string $order = null): v /** * @param string|array $field * @psalm-param SortShape $expectedSort - * - * @dataProvider provideSortOptions */ + #[DataProvider('provideSortOptions')] public function testFromBuilder(array $expectedSort, $field, ?string $order = null): void { $builder = $this->getTestAggregationBuilder(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php index cac71da05d..ad616f6ae4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/DocumentManagerTest.php @@ -32,6 +32,7 @@ use InvalidArgumentException; use MongoDB\BSON\ObjectId; use MongoDB\Client; +use PHPUnit\Framework\Attributes\DataProvider; use RuntimeException; use stdClass; @@ -129,7 +130,7 @@ public static function dataMethodsAffectedByNoObjectArguments(): array ]; } - /** @dataProvider dataMethodsAffectedByNoObjectArguments */ + #[DataProvider('dataMethodsAffectedByNoObjectArguments')] public function testThrowsExceptionOnNonObjectValues(string $methodName): void { $this->expectException(InvalidArgumentException::class); @@ -147,7 +148,7 @@ public static function dataAffectedByErrorIfClosedException(): array ]; } - /** @dataProvider dataAffectedByErrorIfClosedException */ + #[DataProvider('dataAffectedByErrorIfClosedException')] public function testAffectedByErrorIfClosedException(string $methodName): void { $this->expectException(MongoDBException::class); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php index a9469214cb..4047de34cf 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/AtomicSetTest.php @@ -16,6 +16,7 @@ use Documents\Phonebook; use Documents\Phonenumber; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; /** * CollectionPersister will throw exception when collection with atomicSet @@ -86,11 +87,8 @@ public function testAtomicUpsert(): void self::assertEquals('12345678', $user->phonenumbers[0]->getPhonenumber()); } - /** - * @param mixed[]|ArrayCollection|null $clearWith - * - * @dataProvider provideAtomicCollectionUnset - */ + /** @param mixed[]|ArrayCollection|null $clearWith */ + #[DataProvider('provideAtomicCollectionUnset')] public function testAtomicCollectionUnset($clearWith): void { $user = new AtomicSetUser('Maciej'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php index e302606c4e..c4e510740d 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/BinDataTest.php @@ -7,10 +7,11 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use MongoDB\BSON\Binary; +use PHPUnit\Framework\Attributes\DataProvider; class BinDataTest extends BaseTestCase { - /** @dataProvider provideData */ + #[DataProvider('provideData')] public function testBinData(string $field, string $data, int $type): void { $test = new BinDataTestUser(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php index e1a2067956..76fecd68ef 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DateTest.php @@ -9,6 +9,7 @@ use Documents\User; use InvalidArgumentException; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; use function time; @@ -39,9 +40,8 @@ public function testDates(): void /** * @param DateTime|UTCDateTime $oldValue * @param DateTime|UTCDateTime $newValue - * - * @dataProvider provideEquivalentDates */ + #[DataProvider('provideEquivalentDates')] public function testDateInstanceChangeDoesNotCauseUpdateIfValueIsTheSame($oldValue, $newValue): void { $user = new User(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php index ba7aa9f30c..5e36e96909 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php @@ -20,6 +20,7 @@ use MongoDB\BSON\UTCDateTime; use MongoDB\Collection; use MongoDB\Driver\WriteConcern; +use PHPUnit\Framework\Attributes\DataProvider; use ReflectionProperty; use function get_debug_type; @@ -118,7 +119,7 @@ public function testLoadAllWithSortLimitAndSkip(): void self::assertCount(1, $documents); } - /** @dataProvider getTestPrepareFieldNameData */ + #[DataProvider('getTestPrepareFieldNameData')] public function testPrepareFieldName(string $fieldName, string $expected): void { self::assertEquals($expected, $this->documentPersister->prepareFieldName($fieldName)); @@ -167,11 +168,8 @@ public function testExistsInQuery(): void ); } - /** - * @param array $hashId - * - * @dataProvider provideHashIdentifiers - */ + /** @param array $hashId */ + #[DataProvider('provideHashIdentifiers')] public function testPrepareQueryOrNewObjWithHashId(array $hashId): void { $class = DocumentPersisterTestHashIdDocument::class; @@ -183,11 +181,8 @@ public function testPrepareQueryOrNewObjWithHashId(array $hashId): void self::assertEquals($expected, $documentPersister->prepareQueryOrNewObj($value)); } - /** - * @param array $hashId - * - * @dataProvider provideHashIdentifiers - */ + /** @param array $hashId */ + #[DataProvider('provideHashIdentifiers')] public function testPrepareQueryOrNewObjWithHashIdAndInOperators(array $hashId): void { $class = DocumentPersisterTestHashIdDocument::class; @@ -222,9 +217,8 @@ public function testPrepareQueryOrNewObjWithHashIdAndInOperators(array $hashId): /** * @param array $expected * @param array $query - * - * @dataProvider queryProviderForCustomTypeId */ + #[DataProvider('queryProviderForCustomTypeId')] public function testPrepareQueryOrNewObjWithCustomTypedId(array $expected, array $query): void { $class = DocumentPersisterTestDocumentWithCustomId::class; @@ -238,7 +232,7 @@ public function testPrepareQueryOrNewObjWithCustomTypedId(array $expected, array ); } - /** @dataProvider queryProviderForDocumentWithReferenceToDocumentWithCustomTypedId */ + #[DataProvider('queryProviderForDocumentWithReferenceToDocumentWithCustomTypedId')] public function testPrepareQueryOrNewObjWithReferenceToDocumentWithCustomTypedId(Closure $getTestCase): void { Type::registerType('DocumentPersisterCustomId', DocumentPersisterCustomIdType::class); @@ -379,11 +373,8 @@ static function (DocumentManager $dm) use ($getReference): array { ]; } - /** - * @param array $hashId - * - * @dataProvider provideHashIdentifiers - */ + /** @param array $hashId */ + #[DataProvider('provideHashIdentifiers')] public function testPrepareQueryOrNewObjWithSimpleReferenceToTargetDocumentWithHashIdType(array $hashId): void { $class = DocumentPersisterTestDocument::class; @@ -458,11 +449,8 @@ public function testPrepareQueryOrNewObjWithDBRefReferenceToTargetDocumentWithNo self::assertEquals($expected, $documentPersister->prepareQueryOrNewObj($value)); } - /** - * @param array $hashId - * - * @dataProvider provideHashIdentifiers - */ + /** @param array $hashId */ + #[DataProvider('provideHashIdentifiers')] public function testPrepareQueryOrNewObjWithDBRefReferenceToTargetDocumentWithHashIdType(array $hashId): void { $class = DocumentPersisterTestDocument::class; @@ -502,9 +490,8 @@ public function testPrepareQueryOrNewObjWithDBRefReferenceToTargetDocumentWithHa /** * @param array $expected * @param array $query - * - * @dataProvider queryProviderForComplexRefWithObjectValue */ + #[DataProvider('queryProviderForComplexRefWithObjectValue')] public function testPrepareQueryOrNewObjWithComplexRefToTargetDocumentFieldWithObjectValue(array $expected, array $query): void { $class = DocumentPersisterTestDocument::class; @@ -577,11 +564,8 @@ public function testPrepareQueryOrNewObjWithEmbeddedReferenceToTargetDocumentWit self::assertEquals($expected, $documentPersister->prepareQueryOrNewObj($value)); } - /** - * @param array $hashId - * - * @dataProvider provideHashIdentifiers - */ + /** @param array $hashId */ + #[DataProvider('provideHashIdentifiers')] public function testPrepareQueryOrNewObjWithEmbeddedReferenceToTargetDocumentWithHashIdType(array $hashId): void { $class = DocumentPersisterTestDocument::class; @@ -644,9 +628,8 @@ public static function dataProviderTestWriteConcern(): array /** * @param int|string $writeConcern * @psalm-param class-string $class - * - * @dataProvider dataProviderTestWriteConcern */ + #[DataProvider('dataProviderTestWriteConcern')] public function testExecuteInsertsRespectsWriteConcern(string $class, $writeConcern): void { $documentPersister = $this->uow->getDocumentPersister($class); @@ -668,9 +651,8 @@ public function testExecuteInsertsRespectsWriteConcern(string $class, $writeConc /** * @param int|string $writeConcern * @psalm-param class-string $class - * - * @dataProvider dataProviderTestWriteConcern */ + #[DataProvider('dataProviderTestWriteConcern')] public function testExecuteUpsertsRespectsWriteConcern(string $class, $writeConcern): void { $documentPersister = $this->uow->getDocumentPersister($class); @@ -693,9 +675,8 @@ public function testExecuteUpsertsRespectsWriteConcern(string $class, $writeConc /** * @param int|string $writeConcern * @psalm-param class-string $class - * - * @dataProvider dataProviderTestWriteConcern */ + #[DataProvider('dataProviderTestWriteConcern')] public function testRemoveRespectsWriteConcern(string $class, $writeConcern): void { $documentPersister = $this->uow->getDocumentPersister($class); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EnsureShardingTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EnsureShardingTest.php index 3456f4a0f7..e4b3061b76 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/EnsureShardingTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/EnsureShardingTest.php @@ -9,10 +9,11 @@ use Documents\Sharded\ShardedByUser; use Documents\Sharded\ShardedOne; use Documents\Sharded\ShardedOneWithDifferentKey; +use PHPUnit\Framework\Attributes\Group; use function iterator_to_array; -/** @group sharding */ +#[Group('sharding')] class EnsureShardingTest extends BaseTestCase { public function setUp(): void diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php index 1244ea5f08..6e2bc763dc 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/FunctionalTest.php @@ -49,6 +49,7 @@ use Documents\UserUpsertIdStrategyNone; use InvalidArgumentException; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; use function assert; use function bcscale; @@ -80,11 +81,8 @@ public static function provideUpsertObjects(): array ]; } - /** - * @param ObjectId|string $id - * - * @dataProvider provideUpsertObjects - */ + /** @param ObjectId|string $id */ + #[DataProvider('provideUpsertObjects')] public function testUpsertObject(string $className, $id, string $discriminator): void { $user = new $className(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php index 268b9b3097..71dfbb25e8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/IdTest.php @@ -14,6 +14,7 @@ use MongoDB\BSON\Binary; use MongoDB\BSON\ObjectId; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; use function class_exists; use function date; @@ -162,11 +163,8 @@ public function testIdGeneratorInstance(): void self::assertEquals('test', $class->idGenerator->getSalt()); } - /** - * @param int|float $user2Id - * - * @dataProvider provideEqualButNotIdenticalIds - */ + /** @param int|float $user2Id */ + #[DataProvider('provideEqualButNotIdenticalIds')] public function testEqualButNotIdenticalIds(string $user1Id, $user2Id): void { self::assertNotSame($user1Id, $user2Id); @@ -211,9 +209,8 @@ public static function provideEqualButNotIdenticalIds(): array /** * @param mixed $id * @param mixed $expected - * - * @dataProvider getTestIdTypesAndStrategiesData */ + #[DataProvider('getTestIdTypesAndStrategiesData')] public function testIdTypesAndStrategies(string $type, string $strategy, $id = null, $expected = null, ?string $expectedMongoType = null): void { $className = $this->createIdTestClass($type, $strategy); @@ -308,7 +305,7 @@ public static function getTestIdTypesAndStrategiesData(): array ]; } - /** @dataProvider getTestBinIdsData */ + #[DataProvider('getTestBinIdsData')] public function testBinIds(string $type, int $expectedMongoBinDataType, string $id): void { $className = $this->createIdTestClass($type, 'none'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php index c14be0c950..a12014a99a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php @@ -20,6 +20,7 @@ use MongoDB\BSON\Decimal128; use MongoDB\BSON\ObjectId; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function time; @@ -284,7 +285,7 @@ public function testLockDecimal128ThrowsException(): void $this->dm->flush(); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testLockVersionedDocument(): void { $article = new LockInt(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php index 57a0502e47..e7f4b7a887 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/MemoryUsageTest.php @@ -7,6 +7,8 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsPhonenumber; use Documents\CmsUser; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use function current; use function end; @@ -17,14 +19,13 @@ use function round; use function sprintf; -/** @group performance */ +#[Group('performance')] class MemoryUsageTest extends BaseTestCase { /** * Output for jwage "Memory increased by 14.09 kb" - * - * @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testMemoryUsage(): void { $memoryUsage = []; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php index b4d9ff80d0..80020bbf3c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/NestedCollectionsTest.php @@ -10,10 +10,11 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\Phonebook; use Documents\Phonenumber; +use PHPUnit\Framework\Attributes\DataProvider; class NestedCollectionsTest extends BaseTestCase { - /** @dataProvider provideStrategy */ + #[DataProvider('provideStrategy')] public function testStrategy(string $field): void { $doc = new DocWithNestedCollections(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/QueryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/QueryTest.php index 0bdaec1cf9..e57c09f606 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/QueryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/QueryTest.php @@ -18,6 +18,7 @@ use MongoDB\BSON\ObjectId; use MongoDB\BSON\Regex; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function array_values; use function assert; @@ -532,9 +533,8 @@ public function testPopLast(): void /** * Checks that the query class runs a ReplaceOne operation internally - * - * @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testReplaceDocumentRunsReplaceOperation(): void { $this->dm->createQueryBuilder(Article::class) @@ -563,7 +563,7 @@ public function testReplaceMultipleCausesException(): void ->execute(); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testFindAndReplaceDocumentRunsFindAndReplaceOperation(): void { $this->dm->createQueryBuilder(Article::class) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php index df97dbb373..90bfecd8c5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/RawTypeTest.php @@ -8,14 +8,12 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use MongoDB\BSON\ObjectId; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; class RawTypeTest extends BaseTestCase { - /** - * @param mixed $value - * - * @dataProvider getTestRawTypeData - */ + /** @param mixed $value */ + #[DataProvider('getTestRawTypeData')] public function testRawType($value): void { $test = new RawType(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php index 925f8b3a2c..f27f8fbb68 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php @@ -12,6 +12,7 @@ use Documents\User; use MongoDB\Driver\ReadPreference; use MongoDB\Driver\WriteConcern; +use PHPUnit\Framework\Attributes\DataProvider; /** @psalm-type ReadPreferenceTagShape = array{dc?: string, usage?: string} */ class ReadPreferenceTest extends BaseTestCase @@ -43,11 +44,8 @@ public function testHintIsNotSetByDefault(): void self::assertArrayNotHasKey(Query::HINT_READ_PREFERENCE, $groups->getHints()); } - /** - * @psalm-param ReadPreferenceTagShape[] $tags - * - * @dataProvider provideReadPreferenceHints - */ + /** @psalm-param ReadPreferenceTagShape[] $tags */ + #[DataProvider('provideReadPreferenceHints')] public function testHintIsSetOnQuery(int $readPreference, array $tags = []): void { $this->skipTestIfSharded(User::class); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencePrimerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencePrimerTest.php index ac5c059296..9468ea2b8a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencePrimerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencePrimerTest.php @@ -32,6 +32,7 @@ use Documents\User; use InvalidArgumentException; use MongoDB\Driver\ReadPreference; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use ProxyManager\Proxy\GhostObjectInterface; use function assert; @@ -69,7 +70,7 @@ public function testPrimeReferencesShouldRequireOwningSideReferenceMapping(): vo ->toArray(); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testFieldPrimingCanBeToggled(): void { $this->dm->createQueryBuilder(User::class) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ShardKeyTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ShardKeyTest.php index ab5494361f..e5aa6de7bc 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/ShardKeyTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/ShardKeyTest.php @@ -9,11 +9,12 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\Sharded\ShardedOne; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\Group; use function assert; use function end; -/** @group sharding */ +#[Group('sharding')] class ShardKeyTest extends BaseTestCase { private CommandLogger $logger; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php index 49ac2c935e..78b2e17305 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/SplObjectHashCollisionsTest.php @@ -8,15 +8,13 @@ use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; use ReflectionObject; class SplObjectHashCollisionsTest extends BaseTestCase { - /** - * @param callable(DocumentManager, object=): void $f - * - * @dataProvider provideParentAssociationsIsCleared - */ + /** @param callable(DocumentManager, object=): void $f */ + #[DataProvider('provideParentAssociationsIsCleared')] public function testParentAssociationsIsCleared(callable $f): void { $d = new SplColDoc(); @@ -32,11 +30,8 @@ public function testParentAssociationsIsCleared(callable $f): void $this->expectCount('embeddedDocumentsRegistry', 0); } - /** - * @param callable(DocumentManager, object=): void $f - * - * @dataProvider provideParentAssociationsIsCleared - */ + /** @param callable(DocumentManager, object=): void $f */ + #[DataProvider('provideParentAssociationsIsCleared')] public function testParentAssociationsLeftover(callable $f, int $leftover): void { $d = new SplColDoc(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/TestTargetDocument.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/TestTargetDocument.php index 2b6e68fc54..d7c6bad7e0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/TestTargetDocument.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/TestTargetDocument.php @@ -6,10 +6,11 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; class TargetDocumentTest extends BaseTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testMappedSuperClassAsTargetDocument(): void { $test = new TargetDocumentTestDocument(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php index e030d816f1..98be7e8504 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1058Test.php @@ -10,12 +10,13 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Exception; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function array_merge; class GH1058Test extends BaseTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testModifyingDuringOnFlushEventNewDocument(): void { $this->dm->getEventManager()->addEventListener([Events::onFlush], new GH1058Listener()); @@ -25,7 +26,7 @@ public function testModifyingDuringOnFlushEventNewDocument(): void $this->dm->flush(); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testModifyingDuringOnFlushEventNewDocumentWithId(): void { $this->dm->getEventManager()->addEventListener([Events::onFlush], new GH1058Listener()); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php index 932541aafc..092778668a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1229Test.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; use function count; @@ -41,7 +42,7 @@ public function setUp(): void $this->secondParentId = $secondParent->id; } - /** @group m */ + #[Group('m')] public function testMethodAWithoutClone(): void { $firstParent = $this->dm->find(GH1229Parent::CLASSNAME, $this->firstParentId); @@ -87,7 +88,7 @@ public function testMethodAWithoutClone(): void self::assertInstanceOf(GH1229ChildTypeB::CLASSNAME, $children[1]); } - /** @group m */ + #[Group('m')] public function testMethodAWithClone(): void { $firstParent = $this->dm->find(GH1229Parent::CLASSNAME, $this->firstParentId); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php index 753cc0e49a..6153e7ccda 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1232Test.php @@ -10,12 +10,13 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Repository\DocumentRepository; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function assert; class GH1232Test extends BaseTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testRemoveDoesNotCauseErrors(): void { $post = new GH1232Post(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php index 48c19f9b22..626b9a05a1 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1275Test.php @@ -10,6 +10,7 @@ use Doctrine\ODM\MongoDB\Mapping\ClassMetadata; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use function array_map; @@ -145,7 +146,7 @@ public static function getCollectionStrategies(): array ]; } - /** @dataProvider getCollectionStrategies */ + #[DataProvider('getCollectionStrategies')] public function testResortEmbedManyCollection(string $strategy): void { $getNameCallback = static fn (Element $element) => $element->name; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php index 7a346cd04e..32ea5356f2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php @@ -8,10 +8,11 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\Group; class GH1346Test extends BaseTestCase { - /** @group GH1346Test */ + #[Group('GH1346Test')] public function testPublicProperty(): void { $referenced1 = new GH1346ReferencedDocument(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php index f8a695cd1d..28c2a14df4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1428Test.php @@ -6,10 +6,11 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; class GH1428Test extends BaseTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testShortNameLossOnReplacingMiddleEmbeddedDocOfNestedEmbedding(): void { $owner = new GH1428Document(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php index 21b080383f..4b087eb606 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2002Test.php @@ -7,16 +7,14 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Mapping\MappingException; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; use function sprintf; class GH2002Test extends BaseTestCase { - /** - * @param array $expectedReference - * - * @dataProvider getValidReferenceData - */ + /** @param array $expectedReference */ + #[DataProvider('getValidReferenceData')] public function testBuildingReferenceCreatesCorrectStructure(array $expectedReference, object $document): void { $this->dm->persist($document); @@ -59,7 +57,7 @@ public static function getValidReferenceData(): array ]; } - /** @dataProvider getInvalidReferenceData */ + #[DataProvider('getInvalidReferenceData')] public function testBuildingReferenceForUnlistedClassCausesException(string $expectedExceptionMessage, object $document): void { $this->dm->persist($document); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2251Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2251Test.php index 129690dc4d..a9c3bb1ebd 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2251Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2251Test.php @@ -7,13 +7,11 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\User; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\TestWith; class GH2251Test extends BaseTestCase { - /** - * @testWith ["groups"] - * ["groupsSimple"] - */ + #[TestWith(['groups', 'groupsSimple'])] public function testElemMatchQuery(string $fieldName): void { $builder = $this->dm->createQueryBuilder(User::class); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php index 1a1a024c96..809638fe9c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH560Test.php @@ -9,16 +9,14 @@ use Doctrine\ODM\MongoDB\Events; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; use function get_class; class GH560Test extends BaseTestCase { - /** - * @param int|string $id - * - * @dataProvider provideDocumentIds - */ + /** @param int|string $id */ + #[DataProvider('provideDocumentIds')] public function testPersistListenersAreCalled($id): void { $listener = new GH560EventSubscriber([ @@ -41,11 +39,8 @@ public function testPersistListenersAreCalled($id): void self::assertEquals($called, $listener->called); } - /** - * @param int|string $id - * - * @dataProvider provideDocumentIds - */ + /** @param int|string $id */ + #[DataProvider('provideDocumentIds')] public function testDocumentWithCustomIdStrategyIsSavedAndFoundFromDatabase($id): void { $doc = new GH560Document($id, 'test'); @@ -57,11 +52,8 @@ public function testDocumentWithCustomIdStrategyIsSavedAndFoundFromDatabase($id) self::assertEquals($id, $doc->id); } - /** - * @param int|string $id - * - * @dataProvider provideDocumentIds - */ + /** @param int|string $id */ + #[DataProvider('provideDocumentIds')] public function testUpdateListenersAreCalled($id): void { $listener = new GH560EventSubscriber([ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php index a582fbc5f1..23a8a97c47 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH852Test.php @@ -12,11 +12,12 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use MongoDB\BSON\Binary; +use PHPUnit\Framework\Attributes\DataProvider; use ProxyManager\Proxy\GhostObjectInterface; class GH852Test extends BaseTestCase { - /** @dataProvider provideIdGenerators */ + #[DataProvider('provideIdGenerators')] public function testA(Closure $idGenerator): void { $parent = new GH852Document(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM160Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM160Test.php index c94cf6dbaa..b261cff6c1 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM160Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/MODM160Test.php @@ -6,10 +6,11 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\Functional\Ticket\MODM160; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; class MODM160Test extends BaseTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testEmbedManyInArrayMergeNew(): void { // create a test document @@ -27,7 +28,7 @@ public function testEmbedManyInArrayMergeNew(): void $this->dm->merge($test); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testEmbedManyInArrayCollectionMergeNew(): void { // create a test document @@ -45,7 +46,7 @@ public function testEmbedManyInArrayCollectionMergeNew(): void $this->dm->merge($test); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testEmbedOneMergeNew(): void { // create a test document diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php index b3f108aed7..7534703110 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php @@ -11,6 +11,7 @@ use Doctrine\ODM\MongoDB\Mapping\MappingException; use Documents\CmsUser; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; use stdClass; abstract class AbstractAnnotationDriverTestCase extends AbstractMappingDriverTestCase @@ -152,7 +153,7 @@ public function testDocumentAnnotationCanSpecifyWriteConcern(): void self::assertNull($cm->writeConcern); } - /** @dataProvider provideClassCanBeMappedByOneAbstractDocument */ + #[DataProvider('provideClassCanBeMappedByOneAbstractDocument')] public function testClassCanBeMappedByOneAbstractDocument(object $wrong, string $messageRegExp): void { $this->expectException(MappingException::class); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractMappingDriverTestCase.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractMappingDriverTestCase.php index 7673d1b877..cb8b3507e8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractMappingDriverTestCase.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractMappingDriverTestCase.php @@ -23,6 +23,8 @@ use Documents\Suit; use Documents\UserTyped; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function key; use function sprintf; @@ -38,11 +40,8 @@ protected static function createMetadataDriverImpl(): MappingDriver return static::loadDriver(); } - /** - * @return ClassMetadata - * - * @doesNotPerformAssertions - */ + /** @return ClassMetadata */ + #[DoesNotPerformAssertions] public function testLoadMapping(): ClassMetadata { return $this->dm->getClassMetadata(AbstractMappingDriverUser::class); @@ -52,9 +51,8 @@ public function testLoadMapping(): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testLoadMapping */ + #[Depends('testLoadMapping')] public function testDocumentCollectionNameAndInheritance(ClassMetadata $class): ClassMetadata { self::assertEquals('cms_users', $class->getCollection()); @@ -67,9 +65,8 @@ public function testDocumentCollectionNameAndInheritance(ClassMetadata $class): * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testLoadMapping */ + #[Depends('testLoadMapping')] public function testDocumentMarkedAsReadOnly(ClassMetadata $class): ClassMetadata { self::assertTrue($class->isReadOnly); @@ -81,9 +78,8 @@ public function testDocumentMarkedAsReadOnly(ClassMetadata $class): ClassMetadat * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testDocumentCollectionNameAndInheritance */ + #[Depends('testDocumentCollectionNameAndInheritance')] public function testDocumentLevelReadPreference(ClassMetadata $class): ClassMetadata { self::assertEquals('primaryPreferred', $class->readPreference); @@ -100,9 +96,8 @@ public function testDocumentLevelReadPreference(ClassMetadata $class): ClassMeta * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testDocumentCollectionNameAndInheritance */ + #[Depends('testDocumentCollectionNameAndInheritance')] public function testDocumentLevelWriteConcern(ClassMetadata $class): ClassMetadata { self::assertEquals(1, $class->getWriteConcern()); @@ -114,9 +109,8 @@ public function testDocumentLevelWriteConcern(ClassMetadata $class): ClassMetada * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testDocumentLevelWriteConcern */ + #[Depends('testDocumentLevelWriteConcern')] public function testFieldMappings(ClassMetadata $class): ClassMetadata { self::assertCount(14, $class->fieldMappings); @@ -130,11 +124,8 @@ public function testFieldMappings(ClassMetadata $class): ClassMetadata return $class; } - /** - * @param ClassMetadata $class - * - * @depends testDocumentCollectionNameAndInheritance - */ + /** @param ClassMetadata $class */ + #[Depends('testDocumentCollectionNameAndInheritance')] public function testAssociationMappings(ClassMetadata $class): void { self::assertCount(6, $class->associationMappings); @@ -146,11 +137,8 @@ public function testAssociationMappings(ClassMetadata $class): void self::assertTrue(isset($class->associationMappings['otherPhonenumbers'])); } - /** - * @param ClassMetadata $class - * - * @depends testDocumentCollectionNameAndInheritance - */ + /** @param ClassMetadata $class */ + #[Depends('testDocumentCollectionNameAndInheritance')] public function testGetAssociationTargetClass(ClassMetadata $class): void { self::assertEquals(Address::class, $class->getAssociationTargetClass('address')); @@ -161,11 +149,8 @@ public function testGetAssociationTargetClass(ClassMetadata $class): void self::assertNull($class->getAssociationTargetClass('otherPhonenumbers')); } - /** - * @param ClassMetadata $class - * - * @depends testDocumentCollectionNameAndInheritance - */ + /** @param ClassMetadata $class */ + #[Depends('testDocumentCollectionNameAndInheritance')] public function testGetAssociationTargetClassThrowsExceptionWhenEmpty(ClassMetadata $class): void { $this->expectException(InvalidArgumentException::class); @@ -176,9 +161,8 @@ public function testGetAssociationTargetClassThrowsExceptionWhenEmpty(ClassMetad * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testDocumentCollectionNameAndInheritance */ + #[Depends('testDocumentCollectionNameAndInheritance')] public function testStringFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals('string', $class->fieldMappings['name']['type']); @@ -190,9 +174,8 @@ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testFieldMappings */ + #[Depends('testFieldMappings')] public function testIdentifier(ClassMetadata $class): ClassMetadata { self::assertEquals('identifier', $class->identifier); @@ -220,9 +203,8 @@ public function testFieldTypeFromReflection(): void * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testFieldMappings */ + #[Depends('testFieldMappings')] public function testVersionFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals('int', $class->fieldMappings['version']['type']); @@ -235,9 +217,8 @@ public function testVersionFieldMappings(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testFieldMappings */ + #[Depends('testFieldMappings')] public function testLockFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals('int', $class->fieldMappings['lock']['type']); @@ -250,9 +231,8 @@ public function testLockFieldMappings(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testIdentifier */ + #[Depends('testIdentifier')] public function testAssocations(ClassMetadata $class): ClassMetadata { self::assertCount(14, $class->fieldMappings); @@ -264,9 +244,8 @@ public function testAssocations(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testAssocations */ + #[Depends('testAssocations')] public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->fieldMappings['address'])); @@ -285,9 +264,8 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testOwningOneToOneAssociation */ + #[Depends('testOwningOneToOneAssociation')] public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata { $expectedLifecycleCallbacks = [ @@ -304,9 +282,8 @@ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testLifecycleCallbacks */ + #[Depends('testLifecycleCallbacks')] public function testCustomFieldName(ClassMetadata $class): ClassMetadata { self::assertEquals('name', $class->fieldMappings['name']['fieldName']); @@ -319,9 +296,8 @@ public function testCustomFieldName(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testCustomFieldName */ + #[Depends('testCustomFieldName')] public function testCustomReferenceFieldName(ClassMetadata $class): ClassMetadata { self::assertEquals('morePhoneNumbers', $class->fieldMappings['morePhoneNumbers']['fieldName']); @@ -334,9 +310,8 @@ public function testCustomReferenceFieldName(ClassMetadata $class): ClassMetadat * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testCustomReferenceFieldName */ + #[Depends('testCustomReferenceFieldName')] public function testCustomEmbedFieldName(ClassMetadata $class): ClassMetadata { self::assertEquals('embeddedPhonenumber', $class->fieldMappings['embeddedPhonenumber']['fieldName']); @@ -349,9 +324,8 @@ public function testCustomEmbedFieldName(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testCustomEmbedFieldName */ + #[Depends('testCustomEmbedFieldName')] public function testDiscriminator(ClassMetadata $class): ClassMetadata { self::assertEquals('discr', $class->discriminatorField); @@ -365,9 +339,8 @@ public function testDiscriminator(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testDiscriminator */ + #[Depends('testDiscriminator')] public function testEmbedDiscriminator(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->fieldMappings['otherPhonenumbers']['discriminatorField'])); @@ -387,9 +360,8 @@ public function testEmbedDiscriminator(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testEmbedDiscriminator */ + #[Depends('testEmbedDiscriminator')] public function testReferenceDiscriminator(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->fieldMappings['phonenumbers']['discriminatorField'])); @@ -409,9 +381,8 @@ public function testReferenceDiscriminator(ClassMetadata $class): ClassMetadata * @param ClassMetadata $class * * @return ClassMetadata - * - * @depends testCustomFieldName */ + #[Depends('testCustomFieldName')] public function testIndexes(ClassMetadata $class): ClassMetadata { $indexes = $class->indexes; @@ -453,11 +424,8 @@ public function testIndexes(ClassMetadata $class): ClassMetadata return $class; } - /** - * @param ClassMetadata $class - * - * @depends testIndexes - */ + /** @param ClassMetadata $class */ + #[Depends('testIndexes')] public function testShardKey(ClassMetadata $class): void { $shardKey = $class->getShardKey(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php index 575fe4db34..771cb4bad5 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php @@ -35,6 +35,7 @@ use Documents\UserTyped; use Generator; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use ProxyManager\Proxy\GhostObjectInterface; use ReflectionClass; use ReflectionException; @@ -382,11 +383,8 @@ public function testMapNotExistingFieldThrowsException(): void $cm->mapField(['fieldName' => 'namee', 'type' => 'string']); } - /** - * @param ClassMetadata $cm - * - * @dataProvider dataProviderMetadataClasses - */ + /** @param ClassMetadata $cm */ + #[DataProvider('dataProviderMetadataClasses')] public function testEmbeddedDocumentWithDiscriminator(ClassMetadata $cm): void { $cm->setDiscriminatorField('discriminator'); @@ -655,11 +653,8 @@ public function testSimpleAsStringReferenceRequiresTargetDocument(): void ]); } - /** - * @param mixed $value - * - * @dataProvider provideRepositoryMethodCanNotBeCombinedWithSkipLimitAndSort - */ + /** @param mixed $value */ + #[DataProvider('provideRepositoryMethodCanNotBeCombinedWithSkipLimitAndSort')] public function testRepositoryMethodCanNotBeCombinedWithSkipLimitAndSort(string $prop, $value): void { $cm = new ClassMetadata('stdClass'); @@ -738,11 +733,8 @@ public function testDefaultStorageStrategyOfEmbeddedDocumentFields(): void self::assertEquals(CollectionHelper::DEFAULT_STRATEGY, $mapping['strategy']); } - /** - * @param array $config - * - * @dataProvider provideOwningAndInversedRefsNeedTargetDocument - */ + /** @param array $config */ + #[DataProvider('provideOwningAndInversedRefsNeedTargetDocument')] public function testOwningAndInversedRefsNeedTargetDocument(array $config): void { $config = array_merge($config, [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTestCase.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTestCase.php index 7eb3cec1cd..7030240eb1 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTestCase.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/AbstractDriverTestCase.php @@ -6,6 +6,7 @@ use Doctrine\Persistence\Mapping\Driver\FileDriver; use Doctrine\Persistence\Mapping\MappingException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; @@ -16,7 +17,7 @@ use function touch; use function unlink; -/** @group DDC-1418 */ +#[Group('DDC-1418')] abstract class AbstractDriverTestCase extends TestCase { protected string $dir; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/XmlDriverTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/XmlDriverTest.php index 428c8a337e..d234c208e0 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/XmlDriverTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/Symfony/XmlDriverTest.php @@ -5,10 +5,11 @@ namespace Doctrine\ODM\MongoDB\Tests\Mapping\Symfony; use Doctrine\ODM\MongoDB\Mapping\Driver\SimplifiedXmlDriver; +use PHPUnit\Framework\Attributes\Group; use function array_flip; -/** @group DDC-1418 */ +#[Group('DDC-1418')] class XmlDriverTest extends AbstractDriverTestCase { protected function getFileExtension(): string diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Performance/HydrationPerformanceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Performance/HydrationPerformanceTest.php index 7b2ec42385..cbfd6b51df 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Performance/HydrationPerformanceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Performance/HydrationPerformanceTest.php @@ -6,6 +6,8 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsUser; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use function gc_collect_cycles; use function memory_get_usage; @@ -13,14 +15,13 @@ use const PHP_EOL; -/** @group performance */ +#[Group('performance')] class HydrationPerformanceTest extends BaseTestCase { /** * [jwage: 10000 objects in ~6 seconds] - * - * @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testHydrationPerformance(): void { $s = microtime(true); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Performance/InsertPerformanceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Performance/InsertPerformanceTest.php index 3e641d9415..e4c528dd4f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Performance/InsertPerformanceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Performance/InsertPerformanceTest.php @@ -6,6 +6,8 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsUser; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use function gc_collect_cycles; use function memory_get_usage; @@ -13,14 +15,13 @@ use const PHP_EOL; -/** @group performance */ +#[Group('performance')] class InsertPerformanceTest extends BaseTestCase { /** * [jwage: 10000 objects in ~4 seconds] - * - * @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testInsertPerformance(): void { $s = microtime(true); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php index 0e6214773e..70a622c89a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Performance/MemoryUsageTest.php @@ -7,6 +7,8 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsPhonenumber; use Documents\CmsUser; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use function current; use function end; @@ -19,14 +21,13 @@ use const PHP_EOL; -/** @group performance */ +#[Group('performance')] class MemoryUsageTest extends BaseTestCase { /** * [jwage: Memory increased by 14.09 kb] - * - * @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testMemoryUsage(): void { $memoryUsage = []; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Performance/UnitOfWorkPerformanceTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Performance/UnitOfWorkPerformanceTest.php index 79003dd853..d35f9c7543 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Performance/UnitOfWorkPerformanceTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Performance/UnitOfWorkPerformanceTest.php @@ -6,20 +6,21 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\CmsUser; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use function microtime; use function str_replace; use const PHP_EOL; -/** @group performance */ +#[Group('performance')] class UnitOfWorkPerformanceTest extends BaseTestCase { /** * [jwage: compute changesets for 10000 objects in ~10 seconds] - * - * @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testComputeChanges(): void { $n = 10000; diff --git a/tests/Doctrine/ODM/MongoDB/Tests/PersistentCollectionTest.php b/tests/Doctrine/ODM/MongoDB/Tests/PersistentCollectionTest.php index d1f46b9be2..41b52f1dd2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/PersistentCollectionTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/PersistentCollectionTest.php @@ -12,6 +12,7 @@ use Doctrine\ODM\MongoDB\PersistentCollection; use Documents\User; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -135,9 +136,8 @@ public function testSnapshotIsPreservedDuringSerialization(): void /** * @param stdClass[] $expected * @param stdClass[] $snapshot - * - * @dataProvider dataGetDeletedDocuments */ + #[DataProvider('dataGetDeletedDocuments')] public function testGetDeletedDocuments(array $expected, array $snapshot, Closure $callback): void { $collection = new PersistentCollection(new ArrayCollection(), $this->dm, $this->uow); @@ -209,9 +209,8 @@ static function ($collection) use ($one, $two) { /** * @param stdClass[] $expected * @param stdClass[] $snapshot - * - * @dataProvider dataGetInsertedDocuments */ + #[DataProvider('dataGetInsertedDocuments')] public function testGetInsertedDocuments(array $expected, array $snapshot, Closure $callback): void { $collection = new PersistentCollection(new ArrayCollection(), $this->dm, $this->uow); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php index 0e39e76527..5e3f393f5e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Persisters/PersistenceBuilderTest.php @@ -16,6 +16,7 @@ use Documents\Functional\SameCollection1; use Documents\Functional\SameCollection2; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; use function array_keys; @@ -207,11 +208,8 @@ public function testPrepareUpsertData(): void self::assertEquals($expectedData, $this->pb->prepareUpsertData($comment)); } - /** - * @param array $expectedData - * - * @dataProvider getDocumentsAndExpectedData - */ + /** @param array $expectedData */ + #[DataProvider('getDocumentsAndExpectedData')] public function testPrepareInsertData(object $document, array $expectedData): void { $this->dm->persist($document); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php index 636a4501f2..89293ca49f 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/BuilderTest.php @@ -23,6 +23,7 @@ use MongoDB\BSON\ObjectId; use MongoDB\BSON\Regex; use MongoDB\Driver\ReadPreference; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; @@ -187,11 +188,8 @@ public function testIncludesReferenceToThrowsSpecializedExceptionForConflictingM ->getQuery(); } - /** - * @param class-string $class - * - * @dataProvider provideArrayUpdateOperatorsOnReferenceMany - */ + /** @param class-string $class */ + #[DataProvider('provideArrayUpdateOperatorsOnReferenceMany')] public function testArrayUpdateOperatorsOnReferenceMany(string $class, string $field): void { $f = new Feature('Smarter references'); @@ -213,11 +211,8 @@ public static function provideArrayUpdateOperatorsOnReferenceMany(): Generator yield [ChildC::class, 'featurePartialMany']; } - /** - * @param class-string $class - * - * @dataProvider provideArrayUpdateOperatorsOnReferenceOne - */ + /** @param class-string $class */ + #[DataProvider('provideArrayUpdateOperatorsOnReferenceOne')] public function testArrayUpdateOperatorsOnReferenceOne(string $class, string $field): void { $f = new Feature('Smarter references'); @@ -473,7 +468,7 @@ public function testDeepClone(): void self::assertCount(1, $qb->getQueryArray()); } - /** @dataProvider provideProxiedExprMethods */ + #[DataProvider('provideProxiedExprMethods')] public function testProxiedExprMethods(string $method, array $args = []): void { $expr = $this->getMockExpr(); @@ -564,11 +559,8 @@ public function providePoint(): array ]; } - /** - * @param string[] $args - * - * @dataProvider provideSelectProjections - */ + /** @param string[] $args */ + #[DataProvider('provideSelectProjections')] public function testSelect(array $args, array $expected): void { $qb = $this->getTestQueryBuilder(); @@ -582,11 +574,8 @@ public static function provideSelectProjections(): array return self::provideProjections(true); } - /** - * @param string[] $args - * - * @dataProvider provideExcludeProjections - */ + /** @param string[] $args */ + #[DataProvider('provideExcludeProjections')] public function testExclude(array $args, array $expected): void { $qb = $this->getTestQueryBuilder(); @@ -700,11 +689,8 @@ public function testSortWithFieldNameAndDefaultOrder(): void self::assertEquals(['foo' => 1], $qb->debug('sort')); } - /** - * @param string|int $order - * - * @dataProvider provideSortOrders - */ + /** @param string|int $order */ + #[DataProvider('provideSortOrders')] public function testSortWithFieldNameAndOrder($order, int $expectedOrder): void { $qb = $this->getTestQueryBuilder() @@ -755,7 +741,7 @@ public function testSortMetaDoesNotProjectExistingField(): void self::assertEquals(['score' => ['$meta' => 'textScore']], $qb->debug('sort')); } - /** @dataProvider provideCurrentDateOptions */ + #[DataProvider('provideCurrentDateOptions')] public function testCurrentDateUpdateQuery(string $type): void { $qb = $this->getTestQueryBuilder() diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/CriteriaMergerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/CriteriaMergerTest.php index 57090615a9..981e816928 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/CriteriaMergerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/CriteriaMergerTest.php @@ -5,6 +5,7 @@ namespace Doctrine\ODM\MongoDB\Tests\Query; use Doctrine\ODM\MongoDB\Query\CriteriaMerger; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use function call_user_func_array; @@ -14,9 +15,8 @@ class CriteriaMergerTest extends TestCase /** * @param array> $args * @param array $merged - * - * @dataProvider provideMerge */ + #[DataProvider('provideMerge')] public function testMerge(array $args, array $merged): void { self::assertSame($merged, call_user_func_array([new CriteriaMerger(), 'merge'], $args)); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php index 141f1b4932..64a75e59c9 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php @@ -12,6 +12,7 @@ use GeoJson\Geometry\Point; use GeoJson\Geometry\Polygon; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; class ExprTest extends BaseTestCase { @@ -411,9 +412,8 @@ public static function provideGeoJsonPoint(): array /** * @param Point|array $point * @param array $expected - * - * @dataProvider provideGeoJsonPoint */ + #[DataProvider('provideGeoJsonPoint')] public function testNearWithGeoJsonPoint($point, array $expected): void { $expr = $this->createExpr(); @@ -433,9 +433,8 @@ public function testNearWithLegacyCoordinates(): void /** * @param Point|array $point * @param array $expected - * - * @dataProvider provideGeoJsonPoint */ + #[DataProvider('provideGeoJsonPoint')] public function testNearSphereWithGeoJsonPoint($point, array $expected): void { $expr = $this->createExpr(); @@ -548,9 +547,8 @@ public function testPushWithPosition(): void /** * @param Polygon|array> $geometry * @param array $expected - * - * @dataProvider provideGeoJsonPolygon */ + #[DataProvider('provideGeoJsonPolygon')] public function testGeoIntersects($geometry, array $expected): void { $expr = $this->createExpr(); @@ -579,9 +577,8 @@ public static function provideGeoJsonPolygon(): array /** * @param Polygon|array> $geometry * @param array $expected - * - * @dataProvider provideGeoJsonPolygon */ + #[DataProvider('provideGeoJsonPolygon')] public function testGeoWithin($geometry, array $expected): void { $expr = $this->createExpr(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/FilterCollectionTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/FilterCollectionTest.php index aab2f4bc03..558a467ee3 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/FilterCollectionTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/FilterCollectionTest.php @@ -8,6 +8,7 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\User; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Depends; class FilterCollectionTest extends BaseTestCase { @@ -35,7 +36,7 @@ public function testHasFilter(): void self::assertFalse($filterCollection->has('fakeFilter')); } - /** @depends testEnable */ + #[Depends('testEnable')] public function testIsEnabled(): void { $filterCollection = $this->dm->getFilterCollection(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Query/QueryExpressionVisitorTest.php index 27ebf616c0..8cf2457c8b 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Query/QueryExpressionVisitorTest.php @@ -14,6 +14,7 @@ use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\Bars\Bar; use MongoDB\BSON\Regex; +use PHPUnit\Framework\Attributes\DataProvider; use RuntimeException; class QueryExpressionVisitorTest extends BaseTestCase @@ -30,11 +31,8 @@ public function setUp(): void $this->visitor = new QueryExpressionVisitor($this->queryBuilder); } - /** - * @param array $expectedQuery - * - * @dataProvider provideComparisons - */ + /** @param array $expectedQuery */ + #[DataProvider('provideComparisons')] public function testWalkComparison(Comparison $comparison, array $expectedQuery): void { $expr = $this->visitor->dispatch($comparison); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php index f809c8a7a0..a9bc4686c2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/QueryTest.php @@ -21,6 +21,7 @@ use MongoDB\BSON\ObjectId; use MongoDB\Collection; use MongoDB\Driver\ReadPreference; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use Traversable; @@ -423,11 +424,8 @@ public function testConstructorShouldThrowExceptionForInvalidType(): void new Query($this->dm, new ClassMetadata(User::class), $this->getMockCollection(), ['type' => -1], []); } - /** - * @psalm-param Query::TYPE_* $type - * - * @dataProvider provideQueryTypesThatDoNotReturnAnIterator - */ + /** @psalm-param Query::TYPE_* $type */ + #[DataProvider('provideQueryTypesThatDoNotReturnAnIterator')] public function testGetIteratorShouldThrowExceptionWithoutExecutingForTypesThatDoNotReturnAnIterator(int $type, string $method): void { $collection = $this->getMockCollection(); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php index e16ebb6f58..c9e1a1d79e 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php @@ -31,6 +31,7 @@ use MongoDB\Model\CollectionInfo; use MongoDB\Model\IndexInfo; use MongoDB\Model\IndexInfoIteratorIterator; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Constraint\ArrayHasKey; use PHPUnit\Framework\Constraint\Callback; use PHPUnit\Framework\Constraint\Constraint; @@ -160,11 +161,8 @@ public static function getIndexCreationWriteOptions(): array ]; } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getIndexCreationWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getIndexCreationWriteOptions')] public function testEnsureIndexes(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern, bool $background = false): void { $indexedCollections = array_map( @@ -209,11 +207,8 @@ public function testEnsureIndexes(array $expectedWriteOptions, ?int $maxTimeMs, $this->schemaManager->ensureIndexes($maxTimeMs, $writeConcern, $background); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getIndexCreationWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getIndexCreationWriteOptions')] public function testEnsureDocumentIndexes(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern, bool $background = false): void { $cmsArticleCollectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection(); @@ -231,11 +226,8 @@ public function testEnsureDocumentIndexes(array $expectedWriteOptions, ?int $max $this->schemaManager->ensureDocumentIndexes(CmsArticle::class, $maxTimeMs, $writeConcern, $background); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getIndexCreationWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getIndexCreationWriteOptions')] public function testEnsureDocumentIndexesForGridFSFile(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern, bool $background = false): void { foreach ($this->documentCollections as $class => $collection) { @@ -275,11 +267,8 @@ public function testEnsureDocumentIndexesForGridFSFile(array $expectedWriteOptio $this->schemaManager->ensureDocumentIndexes(File::class, $maxTimeMs, $writeConcern, $background); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getIndexCreationWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getIndexCreationWriteOptions')] public function testEnsureDocumentIndexesWithTwoLevelInheritance(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern, bool $background = false): void { $collectionName = $this->dm->getClassMetadata(CmsProduct::class)->getCollection(); @@ -292,11 +281,8 @@ public function testEnsureDocumentIndexesWithTwoLevelInheritance(array $expected $this->schemaManager->ensureDocumentIndexes(CmsProduct::class, $maxTimeMs, $writeConcern, $background); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testUpdateDocumentIndexesShouldCreateMappedIndexes(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $collectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection(); @@ -317,11 +303,8 @@ public function testUpdateDocumentIndexesShouldCreateMappedIndexes(array $expect $this->schemaManager->updateDocumentIndexes(CmsArticle::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testUpdateDocumentIndexesShouldDeleteUnmappedIndexesBeforeCreatingMappedIndexes(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $collectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection(); @@ -350,11 +333,8 @@ public function testUpdateDocumentIndexesShouldDeleteUnmappedIndexesBeforeCreati $this->schemaManager->updateDocumentIndexes(CmsArticle::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDeleteIndexes(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $views = array_map( @@ -376,11 +356,8 @@ public function testDeleteIndexes(array $expectedWriteOptions, ?int $maxTimeMs, $this->schemaManager->deleteIndexes($maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDeleteDocumentIndexes(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $cmsArticleCollectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection(); @@ -419,11 +396,8 @@ public function testUpdateValidators(): void $this->schemaManager->updateValidators(); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testUpdateDocumentValidator(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $class = $this->dm->getClassMetadata(SchemaValidated::class); @@ -470,11 +444,8 @@ public function testUpdateDocumentValidatorShouldThrowExceptionForMappedSupercla $this->schemaManager->updateDocumentValidator($class->name); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testUpdateDocumentValidatorReset(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $class = $this->dm->getClassMetadata(CmsArticle::class); @@ -494,11 +465,8 @@ public function testUpdateDocumentValidatorReset(array $expectedWriteOptions, ?i $this->schemaManager->updateDocumentValidator($class->name, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testCreateDocumentCollection(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $cm = $this->dm->getClassMetadata(CmsArticle::class); @@ -523,11 +491,8 @@ public function testCreateDocumentCollection(array $expectedWriteOptions, ?int $ $this->schemaManager->createDocumentCollection(CmsArticle::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testCreateDocumentCollectionForFile(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $database = $this->documentDatabases[$this->getDatabaseName($this->dm->getClassMetadata(File::class))]; @@ -539,11 +504,8 @@ public function testCreateDocumentCollectionForFile(array $expectedWriteOptions, $this->schemaManager->createDocumentCollection(File::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testCreateDocumentCollectionWithValidator(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $expectedValidatorJson = <<<'EOT' @@ -584,11 +546,8 @@ public function testCreateDocumentCollectionWithValidator(array $expectedWriteOp $this->schemaManager->createDocumentCollection($cm->name, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testCreateView(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $cm = $this->dm->getClassMetadata(UserName::class); @@ -623,11 +582,8 @@ public function testCreateView(array $expectedWriteOptions, ?int $maxTimeMs, ?Wr $this->schemaManager->createDocumentCollection(UserName::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testCreateCollections(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $class = $this->dm->getClassMetadata(Tournament::class); @@ -653,11 +609,8 @@ public function testCreateCollections(array $expectedWriteOptions, ?int $maxTime self::assertSame(1, array_count_values($createdCollections)['Tournament']); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDropCollections(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { foreach ($this->documentCollections as $collection) { @@ -669,11 +622,8 @@ public function testDropCollections(array $expectedWriteOptions, ?int $maxTimeMs $this->schemaManager->dropCollections($maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDropDocumentCollection(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $cmsArticleCollectionName = $this->dm->getClassMetadata(CmsArticle::class)->getCollection(); @@ -690,11 +640,8 @@ public function testDropDocumentCollection(array $expectedWriteOptions, ?int $ma $this->schemaManager->dropDocumentCollection(CmsArticle::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDropDocumentCollectionForGridFSFile(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { foreach ($this->documentCollections as $collection) { @@ -727,11 +674,8 @@ public function testDropDocumentCollectionForGridFSFile(array $expectedWriteOpti $this->schemaManager->dropDocumentCollection(File::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDropView(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $viewName = $this->dm->getClassMetadata(UserName::class)->getCollection(); @@ -748,11 +692,8 @@ public function testDropView(array $expectedWriteOptions, ?int $maxTimeMs, ?Writ $this->schemaManager->dropDocumentCollection(UserName::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDropDocumentDatabase(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { $cmsArticleDatabaseName = $this->getDatabaseName($this->dm->getClassMetadata(CmsArticle::class)); @@ -770,11 +711,8 @@ public function testDropDocumentDatabase(array $expectedWriteOptions, ?int $maxT $this->schemaManager->dropDocumentDatabase(CmsArticle::class, $maxTimeMs, $writeConcern); } - /** - * @psalm-param IndexOptions $expectedWriteOptions - * - * @dataProvider getWriteOptions - */ + /** @psalm-param IndexOptions $expectedWriteOptions */ + #[DataProvider('getWriteOptions')] public function testDropDatabases(array $expectedWriteOptions, ?int $maxTimeMs, ?WriteConcern $writeConcern): void { foreach ($this->documentDatabases as $database) { @@ -790,9 +728,8 @@ public function testDropDatabases(array $expectedWriteOptions, ?int $maxTimeMs, /** * @param array $mongoIndex * @psalm-param IndexMapping $documentIndex - * - * @dataProvider dataIsMongoIndexEquivalentToDocumentIndex */ + #[DataProvider('dataIsMongoIndexEquivalentToDocumentIndex')] public function testIsMongoIndexEquivalentToDocumentIndex(bool $expected, array $mongoIndex, array $documentIndex): void { $defaultMongoIndex = [ @@ -1003,9 +940,8 @@ public static function dataIsMongoIndexEquivalentToDocumentIndex(): array /** * @param array $mongoIndex * @psalm-param IndexMapping $documentIndex - * - * @dataProvider dataIsMongoTextIndexEquivalentToDocumentIndex */ + #[DataProvider('dataIsMongoTextIndexEquivalentToDocumentIndex')] public function testIsMongoIndexEquivalentToDocumentIndexWithTextIndexes(bool $expected, array $mongoIndex, array $documentIndex): void { $defaultMongoIndex = [ diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php index 06202ef5b5..713cfb7ea2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\ODM\MongoDB\Types\Type; use InvalidArgumentException; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -75,11 +76,8 @@ public function testConvertOldDate(): void self::assertEquals($type->convertToDatabaseValue($timestamp), $type->convertToDatabaseValue($date)); } - /** - * @param mixed $value - * - * @dataProvider provideInvalidDateValues - */ + /** @param mixed $value */ + #[DataProvider('provideInvalidDateValues')] public function testConvertToDatabaseValueWithInvalidValues($value): void { $type = Type::getType(Type::DATE_IMMUTABLE); @@ -98,11 +96,8 @@ public static function provideInvalidDateValues(): array ]; } - /** - * @param mixed $input - * - * @dataProvider provideDatabaseToPHPValues - */ + /** @param mixed $input */ + #[DataProvider('provideDatabaseToPHPValues')] public function testConvertToPHPValue($input, DateTimeImmutable $output): void { $type = Type::getType(Type::DATE_IMMUTABLE); @@ -119,11 +114,8 @@ public function testConvertToPHPValueDoesNotConvertNull(): void self::assertNull($type->convertToPHPValue(null)); } - /** - * @param mixed $input - * - * @dataProvider provideDatabaseToPHPValues - */ + /** @param mixed $input */ + #[DataProvider('provideDatabaseToPHPValues')] public function testClosureToPHP($input, DateTimeImmutable $output): void { $type = Type::getType(Type::DATE_IMMUTABLE); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php index a66c08eeb4..77ae14775a 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/DateTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\ODM\MongoDB\Types\Type; use InvalidArgumentException; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -75,11 +76,8 @@ public function testConvertOldDate(): void self::assertEquals($type->convertToDatabaseValue($timestamp), $type->convertToDatabaseValue($date)); } - /** - * @param mixed $value - * - * @dataProvider provideInvalidDateValues - */ + /** @param mixed $value */ + #[DataProvider('provideInvalidDateValues')] public function testConvertToDatabaseValueWithInvalidValues($value): void { $type = Type::getType(Type::DATE); @@ -98,11 +96,8 @@ public static function provideInvalidDateValues(): array ]; } - /** - * @param mixed $input - * - * @dataProvider provideDatabaseToPHPValues - */ + /** @param mixed $input */ + #[DataProvider('provideDatabaseToPHPValues')] public function testConvertToPHPValue($input, DateTime $output): void { $type = Type::getType(Type::DATE); @@ -119,11 +114,8 @@ public function testConvertToPHPValueDoesNotConvertNull(): void self::assertNull($type->convertToPHPValue(null)); } - /** - * @param mixed $input - * - * @dataProvider provideDatabaseToPHPValues - */ + /** @param mixed $input */ + #[DataProvider('provideDatabaseToPHPValues')] public function testClosureToPHP($input, DateTime $output): void { $type = Type::getType(Type::DATE); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php index 5544b44fe3..ec050bb0f2 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/IdTypeTest.php @@ -6,6 +6,7 @@ use Doctrine\ODM\MongoDB\Types\Type; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IdTypeTest extends TestCase @@ -20,11 +21,8 @@ public function testConvertToDatabaseValue(): void self::assertEquals($identifier, $type->convertToDatabaseValue((string) $identifier), 'ObjectId strings are converted to ObjectId objects'); } - /** - * @param mixed $value - * - * @dataProvider provideInvalidObjectIdConstructorArguments - */ + /** @param mixed $value */ + #[DataProvider('provideInvalidObjectIdConstructorArguments')] public function testConvertToDatabaseValueShouldGenerateObjectIds($value): void { $type = Type::getType('id'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php index ba924e907f..10bdf005db 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php @@ -13,6 +13,7 @@ use MongoDB\BSON\ObjectId; use MongoDB\BSON\Timestamp; use MongoDB\BSON\UTCDateTime; +use PHPUnit\Framework\Attributes\DataProvider; use function md5; use function str_pad; @@ -23,11 +24,8 @@ class TypeTest extends BaseTestCase { - /** - * @param mixed $test - * - * @dataProvider provideTypes - */ + /** @param mixed $test */ + #[DataProvider('provideTypes')] public function testConversion(Type $type, $test): void { self::assertEquals($test, $type->convertToPHPValue($type->convertToDatabaseValue($test))); @@ -63,11 +61,8 @@ public static function provideTypes(): array ]; } - /** - * @param mixed $test - * - * @dataProvider provideTypesForIdempotent - */ + /** @param mixed $test */ + #[DataProvider('provideTypesForIdempotent')] public function testConversionIsIdempotent(Type $type, $test): void { self::assertEquals($test, $type->convertToDatabaseValue($test)); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php b/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php index eb51e61a0b..61a529e06c 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php @@ -24,6 +24,8 @@ use Documents\Functional\NotSaved; use Documents\User; use MongoDB\BSON\ObjectId; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use ProxyManager\Proxy\GhostObjectInterface; use Throwable; @@ -155,7 +157,7 @@ public function testParentAssociations(): void self::assertEquals([$mappingD, $c, 'b.c.d'], $this->uow->getParentAssociation($d)); } - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testPreUpdateTriggeredWithEmptyChangeset(): void { $this->dm->getEventManager()->addEventSubscriber( @@ -248,9 +250,8 @@ public function testComputingChangesetForFileWithoutMetadataThrowsNoError(): voi /** * @param array|null $origData * @param array|null $updateData - * - * @dataProvider getScheduleForUpdateWithArraysTests */ + #[DataProvider('getScheduleForUpdateWithArraysTests')] public function testScheduleForUpdateWithArrays(?array $origData, ?array $updateData, bool $shouldInUpdate): void { $arrayTest = new ArrayTest($origData);