13
13
use Doctrine \Bundle \MongoDBBundle \Tests \DependencyInjection \Fixtures \Bundles \DocumentListenerBundle \EventListener \TestAttributeListener ;
14
14
use Doctrine \ODM \MongoDB \Configuration ;
15
15
use Doctrine \ODM \MongoDB \Mapping \Annotations ;
16
+ use InvalidArgumentException ;
16
17
use MongoDB \Client ;
17
18
use PHPUnit \Framework \Attributes \DataProvider ;
18
19
use PHPUnit \Framework \TestCase ;
@@ -488,6 +489,8 @@ public function testUseTransactionalFlush(): void
488
489
489
490
public function testAutoEncryptionWithKeyVaultClientService (): void
490
491
{
492
+ self ::requireAutoEncryptionSupportInODM ();
493
+
491
494
$ container = $ this ->buildMinimalContainer ();
492
495
$ loader = new DoctrineMongoDBExtension ();
493
496
@@ -538,6 +541,8 @@ public function testAutoEncryptionWithKeyVaultClientService(): void
538
541
539
542
public function testAutoEncryptionWithComplexKmsAndSchemaMap (): void
540
543
{
544
+ self ::requireAutoEncryptionSupportInODM ();
545
+
541
546
$ container = $ this ->buildMinimalContainer ();
542
547
$ loader = new DoctrineMongoDBExtension ();
543
548
@@ -590,6 +595,8 @@ public function testAutoEncryptionWithComplexKmsAndSchemaMap(): void
590
595
591
596
public function testAutoEncryptionWithExtraOptions (): void
592
597
{
598
+ self ::requireAutoEncryptionSupportInODM ();
599
+
593
600
$ container = $ this ->buildMinimalContainer ();
594
601
$ loader = new DoctrineMongoDBExtension ();
595
602
@@ -639,6 +646,8 @@ public function testAutoEncryptionWithExtraOptions(): void
639
646
640
647
public function testAutoEncryptionWithEmptyKmsProvider (): void
641
648
{
649
+ self ::requireAutoEncryptionSupportInODM ();
650
+
642
651
$ container = $ this ->buildMinimalContainer ();
643
652
$ loader = new DoctrineMongoDBExtension ();
644
653
@@ -663,4 +672,36 @@ public function testAutoEncryptionWithEmptyKmsProvider(): void
663
672
self ::assertArrayHasKey ('autoEncryption ' , $ driverOptions );
664
673
self ::assertEquals (['aws ' => new Definition (stdClass::class)], $ driverOptions ['autoEncryption ' ]['kmsProviders ' ]);
665
674
}
675
+
676
+ public function testAutoEncryptionMinimumODMVersion (): void
677
+ {
678
+ if (InstalledVersions::satisfies (new VersionParser (), 'doctrine/mongodb-odm ' , '>=2.12@dev ' )) {
679
+ self ::markTestSkipped ('Installed version of doctrine/mongodb-odm does support auto encryption ' );
680
+ }
681
+
682
+ $ container = $ this ->buildMinimalContainer ();
683
+ $ loader = new DoctrineMongoDBExtension ();
684
+
685
+ $ config = [
686
+ 'connections ' => [
687
+ 'default ' => [
688
+ 'autoEncryption ' => [
689
+ 'kmsProvider ' => ['type ' => 'aws ' ],
690
+ ],
691
+ ],
692
+ ],
693
+ 'document_managers ' => ['default ' => []],
694
+ ];
695
+
696
+ self ::expectException (InvalidArgumentException::class);
697
+ self ::expectExceptionMessage ('The "autoEncryption" option requires doctrine/mongodb-odm version 2.12 or higher ' );
698
+ $ loader ->load ([$ config ], $ container );
699
+ }
700
+
701
+ private static function requireAutoEncryptionSupportInODM (): void
702
+ {
703
+ if (! InstalledVersions::satisfies (new VersionParser (), 'doctrine/mongodb-odm ' , '>=2.12@dev ' )) {
704
+ self ::markTestSkipped ('Installed version of doctrine/mongodb-odm does not support auto encryption ' );
705
+ }
706
+ }
666
707
}
0 commit comments