diff --git a/.gitattributes b/.gitattributes index 0939daedba5..1bc7f690e59 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,7 +8,6 @@ /features export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore -/phpunit_mongodb.xml export-ignore /tests export-ignore /update-js.sh export-ignore /yarn.lock export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index faccaa57ed5..3d6fa355767 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -485,7 +485,7 @@ jobs: run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction mongodb: - name: Behat (PHP ${{ matrix.php }}) (MongoDB) + name: PHPUnit + Behat (PHP ${{ matrix.php }}) (MongoDB) runs-on: ubuntu-latest timeout-minutes: 20 strategy: @@ -529,8 +529,8 @@ jobs: run: vendor/bin/simple-phpunit --version - name: Clear test app cache run: tests/Fixtures/app/console cache:clear --ansi - - name: Run PHPUnit - run: vendor/bin/simple-phpunit + - name: Run PHPUnit tests + run: vendor/bin/simple-phpunit --group mongodb - name: Run Behat tests run: vendor/bin/behat -vv --out=std --format=progress --profile=mongodb --no-interaction @@ -585,8 +585,6 @@ jobs: run: vendor/bin/simple-phpunit --version - name: Clear test app cache run: tests/Fixtures/app/console cache:clear --ansi - - name: Run PHPUnit tests - run: vendor/bin/simple-phpunit - name: Run Behat tests run: vendor/bin/behat --out=std --format=progress --profile=elasticsearch --no-interaction diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4518373e404..7b52597293e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,7 @@ - + diff --git a/phpunit_mongodb.xml b/phpunit_mongodb.xml deleted file mode 100644 index 0ef9e7e4d5b..00000000000 --- a/phpunit_mongodb.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - tests - - - - - - . - - features - tests - vendor - src/Bridge/NelmioApiDoc - src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php - - - - - - - - diff --git a/tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php b/tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php index 0f1f163cc6c..b090f818409 100644 --- a/tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php +++ b/tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php @@ -395,6 +395,36 @@ public function provideApplyTestData(): array ], $filterFactory, ], + 'partial (multiple values)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('CaSE'), + new Regex('SENSitive'), + ], + ], + ], + ], + ], + $filterFactory, + ], + 'partial (multiple values; case insensitive)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('CaSE', 'i'), + new Regex('inSENSitive', 'i'), + ], + ], + ], + ], + ], + $filterFactory, + ], 'start' => [ [ [ @@ -423,6 +453,36 @@ public function provideApplyTestData(): array ], $filterFactory, ], + 'start (multiple values)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('^CaSE'), + new Regex('^SENSitive'), + ], + ], + ], + ], + ], + $filterFactory, + ], + 'start (multiple values; case insensitive)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('^CaSE', 'i'), + new Regex('^inSENSitive', 'i'), + ], + ], + ], + ], + ], + $filterFactory, + ], 'end' => [ [ [ @@ -451,6 +511,36 @@ public function provideApplyTestData(): array ], $filterFactory, ], + 'end (multiple values)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('CaSE$'), + new Regex('SENSitive$'), + ], + ], + ], + ], + ], + $filterFactory, + ], + 'end (multiple values; case insensitive)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('CaSE$', 'i'), + new Regex('inSENSitive$', 'i'), + ], + ], + ], + ], + ], + $filterFactory, + ], 'word_start' => [ [ [ @@ -479,6 +569,36 @@ public function provideApplyTestData(): array ], $filterFactory, ], + 'word_start (multiple values)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('(^CaSE.*|.*\sCaSE.*)'), + new Regex('(^SENSitive.*|.*\sSENSitive.*)'), + ], + ], + ], + ], + ], + $filterFactory, + ], + 'word_start (multiple values; case insensitive)' => [ + [ + [ + '$match' => [ + 'name' => [ + '$in' => [ + new Regex('(^CaSE.*|.*\sCaSE.*)', 'i'), + new Regex('(^inSENSitive.*|.*\sinSENSitive.*)', 'i'), + ], + ], + ], + ], + ], + $filterFactory, + ], 'invalid value for relation' => [ [], $filterFactory, diff --git a/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractorTest.php b/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractorTest.php index 36505c4dc9c..20b864155ea 100644 --- a/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractorTest.php +++ b/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractorTest.php @@ -54,10 +54,8 @@ public function testGetProperties(): void 'date', 'float', 'bool', - 'boolean', 'customFoo', 'int', - 'integer', 'string', 'key', 'hash', @@ -143,9 +141,7 @@ public function typesProvider(): array ['date', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]], ['float', [new Type(Type::BUILTIN_TYPE_FLOAT)]], ['bool', [new Type(Type::BUILTIN_TYPE_BOOL)]], - ['boolean', [new Type(Type::BUILTIN_TYPE_BOOL)]], ['int', [new Type(Type::BUILTIN_TYPE_INT)]], - ['integer', [new Type(Type::BUILTIN_TYPE_INT)]], ['string', [new Type(Type::BUILTIN_TYPE_STRING)]], ['key', [new Type(Type::BUILTIN_TYPE_INT)]], ['hash', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]], diff --git a/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineDummy.php b/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineDummy.php index 64a34ed4f65..053bf0e7357 100644 --- a/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineDummy.php +++ b/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineDummy.php @@ -101,11 +101,6 @@ class DoctrineDummy */ private $bool; - /** - * @Field(type="boolean") - */ - private $boolean; - /** * @Field(type="custom_foo") */ @@ -116,11 +111,6 @@ class DoctrineDummy */ private $int; - /** - * @Field(type="integer") - */ - private $integer; - /** * @Field(type="string") */ diff --git a/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineGeneratedValue.php b/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineGeneratedValue.php index 46ece808957..e286195a2b3 100644 --- a/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineGeneratedValue.php +++ b/tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineGeneratedValue.php @@ -26,7 +26,7 @@ class DoctrineGeneratedValue { /** - * @Id(strategy="INCREMENT", type="integer") + * @Id(strategy="INCREMENT", type="int") */ public $id; diff --git a/tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php b/tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php index 0130565ffcc..879a630431c 100644 --- a/tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php +++ b/tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php @@ -167,7 +167,7 @@ public function testGetSubresource() $dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory); - $context = ['property' => 'relatedDummies', 'identifiers' => [['id', Dummy::class]], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; + $context = ['property' => 'relatedDummies', 'identifiers' => ['id' => [Dummy::class, 'id']], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; $this->assertEquals([], $dataProvider->getSubresource(RelatedDummy::class, ['id' => ['id' => 1]], $context)); } @@ -256,7 +256,7 @@ public function testGetSubSubresourceItem() $dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory); - $context = ['property' => 'thirdLevel', 'identifiers' => [['id', Dummy::class], ['relatedDummies', RelatedDummy::class]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; + $context = ['property' => 'thirdLevel', 'identifiers' => ['id' => [Dummy::class, 'id'], 'relatedDummies' => [RelatedDummy::class, 'id']], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; $this->assertEquals($result, $dataProvider->getSubresource(ThirdLevel::class, ['id' => ['id' => 1], 'relatedDummies' => ['id' => 1]], $context)); } @@ -353,7 +353,7 @@ public function testGetSubSubresourceItemWithExecuteOptions() $dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory); - $context = ['property' => 'thirdLevel', 'identifiers' => [['id', Dummy::class], ['relatedDummies', RelatedDummy::class]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; + $context = ['property' => 'thirdLevel', 'identifiers' => ['id' => [Dummy::class, 'id'], 'relatedDummies' => [RelatedDummy::class, 'id']], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; $this->assertEquals($result, $dataProvider->getSubresource(ThirdLevel::class, ['id' => ['id' => 1], 'relatedDummies' => ['id' => 1]], $context, 'third_level_operation_name')); } @@ -405,7 +405,7 @@ public function testGetSubresourceOneToOneOwningRelation() $dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory); - $context = ['property' => 'ownedDummy', 'identifiers' => [['id', Dummy::class]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; + $context = ['property' => 'ownedDummy', 'identifiers' => ['id' => [Dummy::class, 'id']], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; $this->assertEquals($result, $dataProvider->getSubresource(RelatedOwningDummy::class, ['id' => ['id' => 1]], $context)); } @@ -458,7 +458,7 @@ public function testAggregationResultExtension() $dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory, [$extensionProphecy->reveal()]); - $context = ['property' => 'relatedDummies', 'identifiers' => [['id', Dummy::class]], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; + $context = ['property' => 'relatedDummies', 'identifiers' => ['id' => [Dummy::class, 'id']], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; $this->assertEquals([], $dataProvider->getSubresource(RelatedDummy::class, ['id' => ['id' => 1]], $context)); } @@ -504,11 +504,6 @@ public function testGetSubresourceCollectionItem() $rAggregationBuilder = $this->prophesize(Builder::class); - $rMatch = $this->prophesize(AggregationMatch::class); - $rMatch->equals(2)->shouldBeCalled(); - $rMatch->field('id')->shouldBeCalled()->willReturn($rMatch); - $rAggregationBuilder->match()->shouldBeCalled()->willReturn($rMatch->reveal()); - $rClassMetadataProphecy = $this->prophesize(ClassMetadata::class); $rClassMetadataProphecy->hasAssociation('id')->shouldBeCalled()->willReturn(false); $rClassMetadataProphecy->isIdentifier('id')->shouldBeCalled()->willReturn(true); @@ -539,7 +534,7 @@ public function testGetSubresourceCollectionItem() $dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory); - $context = ['property' => 'id', 'identifiers' => [['id', Dummy::class, true], ['relatedDummies', RelatedDummy::class, true]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; + $context = ['property' => 'id', 'identifiers' => ['id' => [Dummy::class, 'id', true], [RelatedDummy::class, 'relatedDummies', true]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true]; $this->assertEquals($result, $dataProvider->getSubresource(RelatedDummy::class, ['id' => ['id' => 1], 'relatedDummies' => ['id' => 2]], $context)); }