Skip to content

Add back PHPUnit tests with MongoDB #4104

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

Merged
merged 5 commits into from
Mar 1, 2021
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<server name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml" />
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="APP_ENV" value="test" />
<env name="APP_ENV" value="test" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it can be overridden this way.

</php>

<testsuites>
Expand Down
41 changes: 0 additions & 41 deletions phpunit_mongodb.xml

This file was deleted.

120 changes: 120 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
[
[
Expand Down Expand Up @@ -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' => [
[
[
Expand Down Expand Up @@ -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' => [
[
[
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ public function testGetProperties(): void
'date',
'float',
'bool',
'boolean',
'customFoo',
'int',
'integer',
'string',
'key',
'hash',
Expand Down Expand Up @@ -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)]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ class DoctrineDummy
*/
private $bool;

/**
* @Field(type="boolean")
*/
private $boolean;

/**
* @Field(type="custom_foo")
*/
Expand All @@ -116,11 +111,6 @@ class DoctrineDummy
*/
private $int;

/**
* @Field(type="integer")
*/
private $integer;

/**
* @Field(type="string")
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class DoctrineGeneratedValue
{
/**
* @Id(strategy="INCREMENT", type="integer")
* @Id(strategy="INCREMENT", type="int")
*/
public $id;

Expand Down
17 changes: 6 additions & 11 deletions tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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'));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down