Skip to content

Commit 0037f60

Browse files
authored
Add back PHPUnit tests with MongoDB (#4104)
1 parent 4630af7 commit 0037f60

File tree

9 files changed

+131
-74
lines changed

9 files changed

+131
-74
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
/features export-ignore
99
/phpstan.neon.dist export-ignore
1010
/phpunit.xml.dist export-ignore
11-
/phpunit_mongodb.xml export-ignore
1211
/tests export-ignore
1312
/update-js.sh export-ignore
1413
/yarn.lock export-ignore

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ jobs:
485485
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction
486486

487487
mongodb:
488-
name: Behat (PHP ${{ matrix.php }}) (MongoDB)
488+
name: PHPUnit + Behat (PHP ${{ matrix.php }}) (MongoDB)
489489
runs-on: ubuntu-latest
490490
timeout-minutes: 20
491491
strategy:
@@ -529,8 +529,8 @@ jobs:
529529
run: vendor/bin/simple-phpunit --version
530530
- name: Clear test app cache
531531
run: tests/Fixtures/app/console cache:clear --ansi
532-
- name: Run PHPUnit
533-
run: vendor/bin/simple-phpunit
532+
- name: Run PHPUnit tests
533+
run: vendor/bin/simple-phpunit --group mongodb
534534
- name: Run Behat tests
535535
run: vendor/bin/behat -vv --out=std --format=progress --profile=mongodb --no-interaction
536536

@@ -585,8 +585,6 @@ jobs:
585585
run: vendor/bin/simple-phpunit --version
586586
- name: Clear test app cache
587587
run: tests/Fixtures/app/console cache:clear --ansi
588-
- name: Run PHPUnit tests
589-
run: vendor/bin/simple-phpunit
590588
- name: Run Behat tests
591589
run: vendor/bin/behat --out=std --format=progress --profile=elasticsearch --no-interaction
592590

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<server name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml" />
1717
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
1818
<server name="KERNEL_CLASS" value="AppKernel" />
19-
<server name="APP_ENV" value="test" />
19+
<env name="APP_ENV" value="test" />
2020
</php>
2121

2222
<testsuites>

phpunit_mongodb.xml

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,36 @@ public function provideApplyTestData(): array
395395
],
396396
$filterFactory,
397397
],
398+
'partial (multiple values)' => [
399+
[
400+
[
401+
'$match' => [
402+
'name' => [
403+
'$in' => [
404+
new Regex('CaSE'),
405+
new Regex('SENSitive'),
406+
],
407+
],
408+
],
409+
],
410+
],
411+
$filterFactory,
412+
],
413+
'partial (multiple values; case insensitive)' => [
414+
[
415+
[
416+
'$match' => [
417+
'name' => [
418+
'$in' => [
419+
new Regex('CaSE', 'i'),
420+
new Regex('inSENSitive', 'i'),
421+
],
422+
],
423+
],
424+
],
425+
],
426+
$filterFactory,
427+
],
398428
'start' => [
399429
[
400430
[
@@ -423,6 +453,36 @@ public function provideApplyTestData(): array
423453
],
424454
$filterFactory,
425455
],
456+
'start (multiple values)' => [
457+
[
458+
[
459+
'$match' => [
460+
'name' => [
461+
'$in' => [
462+
new Regex('^CaSE'),
463+
new Regex('^SENSitive'),
464+
],
465+
],
466+
],
467+
],
468+
],
469+
$filterFactory,
470+
],
471+
'start (multiple values; case insensitive)' => [
472+
[
473+
[
474+
'$match' => [
475+
'name' => [
476+
'$in' => [
477+
new Regex('^CaSE', 'i'),
478+
new Regex('^inSENSitive', 'i'),
479+
],
480+
],
481+
],
482+
],
483+
],
484+
$filterFactory,
485+
],
426486
'end' => [
427487
[
428488
[
@@ -451,6 +511,36 @@ public function provideApplyTestData(): array
451511
],
452512
$filterFactory,
453513
],
514+
'end (multiple values)' => [
515+
[
516+
[
517+
'$match' => [
518+
'name' => [
519+
'$in' => [
520+
new Regex('CaSE$'),
521+
new Regex('SENSitive$'),
522+
],
523+
],
524+
],
525+
],
526+
],
527+
$filterFactory,
528+
],
529+
'end (multiple values; case insensitive)' => [
530+
[
531+
[
532+
'$match' => [
533+
'name' => [
534+
'$in' => [
535+
new Regex('CaSE$', 'i'),
536+
new Regex('inSENSitive$', 'i'),
537+
],
538+
],
539+
],
540+
],
541+
],
542+
$filterFactory,
543+
],
454544
'word_start' => [
455545
[
456546
[
@@ -479,6 +569,36 @@ public function provideApplyTestData(): array
479569
],
480570
$filterFactory,
481571
],
572+
'word_start (multiple values)' => [
573+
[
574+
[
575+
'$match' => [
576+
'name' => [
577+
'$in' => [
578+
new Regex('(^CaSE.*|.*\sCaSE.*)'),
579+
new Regex('(^SENSitive.*|.*\sSENSitive.*)'),
580+
],
581+
],
582+
],
583+
],
584+
],
585+
$filterFactory,
586+
],
587+
'word_start (multiple values; case insensitive)' => [
588+
[
589+
[
590+
'$match' => [
591+
'name' => [
592+
'$in' => [
593+
new Regex('(^CaSE.*|.*\sCaSE.*)', 'i'),
594+
new Regex('(^inSENSitive.*|.*\sinSENSitive.*)', 'i'),
595+
],
596+
],
597+
],
598+
],
599+
],
600+
$filterFactory,
601+
],
482602
'invalid value for relation' => [
483603
[],
484604
$filterFactory,

tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ public function testGetProperties(): void
5454
'date',
5555
'float',
5656
'bool',
57-
'boolean',
5857
'customFoo',
5958
'int',
60-
'integer',
6159
'string',
6260
'key',
6361
'hash',
@@ -143,9 +141,7 @@ public function typesProvider(): array
143141
['date', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
144142
['float', [new Type(Type::BUILTIN_TYPE_FLOAT)]],
145143
['bool', [new Type(Type::BUILTIN_TYPE_BOOL)]],
146-
['boolean', [new Type(Type::BUILTIN_TYPE_BOOL)]],
147144
['int', [new Type(Type::BUILTIN_TYPE_INT)]],
148-
['integer', [new Type(Type::BUILTIN_TYPE_INT)]],
149145
['string', [new Type(Type::BUILTIN_TYPE_STRING)]],
150146
['key', [new Type(Type::BUILTIN_TYPE_INT)]],
151147
['hash', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]],

tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ class DoctrineDummy
101101
*/
102102
private $bool;
103103

104-
/**
105-
* @Field(type="boolean")
106-
*/
107-
private $boolean;
108-
109104
/**
110105
* @Field(type="custom_foo")
111106
*/
@@ -116,11 +111,6 @@ class DoctrineDummy
116111
*/
117112
private $int;
118113

119-
/**
120-
* @Field(type="integer")
121-
*/
122-
private $integer;
123-
124114
/**
125115
* @Field(type="string")
126116
*/

tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineGeneratedValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
class DoctrineGeneratedValue
2727
{
2828
/**
29-
* @Id(strategy="INCREMENT", type="integer")
29+
* @Id(strategy="INCREMENT", type="int")
3030
*/
3131
public $id;
3232

tests/Bridge/Doctrine/MongoDbOdm/SubresourceDataProviderTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function testGetSubresource()
167167

168168
$dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory);
169169

170-
$context = ['property' => 'relatedDummies', 'identifiers' => [['id', Dummy::class]], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
170+
$context = ['property' => 'relatedDummies', 'identifiers' => ['id' => [Dummy::class, 'id']], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
171171

172172
$this->assertEquals([], $dataProvider->getSubresource(RelatedDummy::class, ['id' => ['id' => 1]], $context));
173173
}
@@ -256,7 +256,7 @@ public function testGetSubSubresourceItem()
256256

257257
$dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory);
258258

259-
$context = ['property' => 'thirdLevel', 'identifiers' => [['id', Dummy::class], ['relatedDummies', RelatedDummy::class]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
259+
$context = ['property' => 'thirdLevel', 'identifiers' => ['id' => [Dummy::class, 'id'], 'relatedDummies' => [RelatedDummy::class, 'id']], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
260260

261261
$this->assertEquals($result, $dataProvider->getSubresource(ThirdLevel::class, ['id' => ['id' => 1], 'relatedDummies' => ['id' => 1]], $context));
262262
}
@@ -353,7 +353,7 @@ public function testGetSubSubresourceItemWithExecuteOptions()
353353

354354
$dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory);
355355

356-
$context = ['property' => 'thirdLevel', 'identifiers' => [['id', Dummy::class], ['relatedDummies', RelatedDummy::class]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
356+
$context = ['property' => 'thirdLevel', 'identifiers' => ['id' => [Dummy::class, 'id'], 'relatedDummies' => [RelatedDummy::class, 'id']], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
357357

358358
$this->assertEquals($result, $dataProvider->getSubresource(ThirdLevel::class, ['id' => ['id' => 1], 'relatedDummies' => ['id' => 1]], $context, 'third_level_operation_name'));
359359
}
@@ -405,7 +405,7 @@ public function testGetSubresourceOneToOneOwningRelation()
405405

406406
$dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory);
407407

408-
$context = ['property' => 'ownedDummy', 'identifiers' => [['id', Dummy::class]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
408+
$context = ['property' => 'ownedDummy', 'identifiers' => ['id' => [Dummy::class, 'id']], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
409409

410410
$this->assertEquals($result, $dataProvider->getSubresource(RelatedOwningDummy::class, ['id' => ['id' => 1]], $context));
411411
}
@@ -458,7 +458,7 @@ public function testAggregationResultExtension()
458458

459459
$dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory, [$extensionProphecy->reveal()]);
460460

461-
$context = ['property' => 'relatedDummies', 'identifiers' => [['id', Dummy::class]], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
461+
$context = ['property' => 'relatedDummies', 'identifiers' => ['id' => [Dummy::class, 'id']], 'collection' => true, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
462462

463463
$this->assertEquals([], $dataProvider->getSubresource(RelatedDummy::class, ['id' => ['id' => 1]], $context));
464464
}
@@ -504,11 +504,6 @@ public function testGetSubresourceCollectionItem()
504504

505505
$rAggregationBuilder = $this->prophesize(Builder::class);
506506

507-
$rMatch = $this->prophesize(AggregationMatch::class);
508-
$rMatch->equals(2)->shouldBeCalled();
509-
$rMatch->field('id')->shouldBeCalled()->willReturn($rMatch);
510-
$rAggregationBuilder->match()->shouldBeCalled()->willReturn($rMatch->reveal());
511-
512507
$rClassMetadataProphecy = $this->prophesize(ClassMetadata::class);
513508
$rClassMetadataProphecy->hasAssociation('id')->shouldBeCalled()->willReturn(false);
514509
$rClassMetadataProphecy->isIdentifier('id')->shouldBeCalled()->willReturn(true);
@@ -539,7 +534,7 @@ public function testGetSubresourceCollectionItem()
539534

540535
$dataProvider = new SubresourceDataProvider($managerRegistryProphecy->reveal(), $this->resourceMetadataFactoryProphecy->reveal(), $propertyNameCollectionFactory, $propertyMetadataFactory);
541536

542-
$context = ['property' => 'id', 'identifiers' => [['id', Dummy::class, true], ['relatedDummies', RelatedDummy::class, true]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
537+
$context = ['property' => 'id', 'identifiers' => ['id' => [Dummy::class, 'id', true], [RelatedDummy::class, 'relatedDummies', true]], 'collection' => false, IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER => true];
543538

544539
$this->assertEquals($result, $dataProvider->getSubresource(RelatedDummy::class, ['id' => ['id' => 1], 'relatedDummies' => ['id' => 2]], $context));
545540
}

0 commit comments

Comments
 (0)