Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PHPUnit 10 #2564

Merged
merged 3 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"phpbench/phpbench": "^1.0.0",
"phpstan/phpstan": "^1.10.11",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.6 || ^10.0.15",
"phpunit/phpunit": "^10.4",
"squizlabs/php_codesniffer": "^3.5",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"vimeo/psalm": "^5.9.0"
Expand Down
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\\<class@anonymous/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest\\.php\\:230\\>\\:\\: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\\<class@anonymous/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest\\.php\\:231\\>\\:\\: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\\<class@anonymous/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest\\.php\\:249\\>\\:\\: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\\<class@anonymous/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest\\.php\\:250\\>\\:\\: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

Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
failOnRisky="true"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="Doctrine ODM MongoDB Test Suite">
<directory>./tests/Doctrine/</directory>
</testsuite>
</testsuites>
<coverage>
<source>
<include>
<directory suffix=".php">./lib/Doctrine/ODM/MongoDB</directory>
</include>
</coverage>
</source>
<groups>
<exclude>
<group>performance</group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ public static function provideTypeExpressionOperators(): Generator
];
}

public function provideWindowExpressionOperators(): Generator
public static function provideWindowExpressionOperators(): Generator
{
yield 'covariancePop' => [
'expected' => ['$covariancePop' => ['$field1', '$field2']],
Expand Down
75 changes: 37 additions & 38 deletions tests/Doctrine/ODM/MongoDB/Tests/Aggregation/ExprTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -17,26 +18,25 @@ class ExprTest extends BaseTestCase
/**
* @param array<string, string> $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();
Expand All @@ -49,26 +49,25 @@ public function testGenericOperator(array $expected, string $operator, $args): v
/**
* @param array<string, string> $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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -22,9 +23,8 @@ class BucketAutoTest extends BaseTestCase
/**
* @param array<string, string> $expected
* @param mixed[]|Closure(Expr): mixed[] $args
*
* @dataProvider provideGroupAccumulatorExpressionOperators
*/
#[DataProvider('provideGroupAccumulatorExpressionOperators')]
public function testGroupAccumulators(array $expected, string $operator, $args): void
{
$args = $this->resolveArgs($args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -22,9 +23,8 @@ class BucketTest extends BaseTestCase
/**
* @param array<string, string> $expected
* @param mixed[]|Closure(Expr): mixed[] $args
*
* @dataProvider provideGroupAccumulatorExpressionOperators
*/
#[DataProvider('provideGroupAccumulatorExpressionOperators')]
public function testGroupAccumulators(array $expected, string $operator, $args): void
{
$args = $this->resolveArgs($args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,9 +150,8 @@ public static function provideEmployeeAggregations(): array
/**
* @param Closure(Builder): GraphLookup $addGraphLookupStage
* @param array<string, string> $expectedFields
*
* @dataProvider provideEmployeeAggregations
*/
#[DataProvider('provideEmployeeAggregations')]
public function testWithEmployees(Closure $addGraphLookupStage, array $expectedFields): void
{
$this->insertEmployeeTestData();
Expand Down Expand Up @@ -222,9 +222,8 @@ public static function provideTravellerAggregations(): array
/**
* @param Closure(Builder): GraphLookup $addGraphLookupStage
* @param array<string, string> $expectedFields
*
* @dataProvider provideTravellerAggregations
*/
#[DataProvider('provideTravellerAggregations')]
public function testWithTraveller(Closure $addGraphLookupStage, array $expectedFields): void
{
$this->insertTravellerTestData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -19,9 +20,8 @@ class GroupTest extends BaseTestCase
/**
* @param array<string, string> $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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Documents\User;
use Generator;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;

use function is_callable;

Expand Down Expand Up @@ -80,11 +81,8 @@ public static function providePipeline(): Generator
];
}

/**
* @param array<array<string, mixed>>|callable $pipeline
*
* @dataProvider providePipeline
*/
/** @param array<array<string, mixed>>|callable $pipeline */
#[DataProvider('providePipeline')]
public function testStageWithPipeline($pipeline): void
{
if (is_callable($pipeline)) {
Expand Down
32 changes: 16 additions & 16 deletions tests/Doctrine/ODM/MongoDB/Tests/Aggregation/Stage/OperatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -20,23 +21,22 @@ class OperatorTest extends BaseTestCase
/**
* @param array<string, mixed> $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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
Expand Down
Loading
Loading