1717use MongoDB \Operation \Count ;
1818use MongoDB \Tests \CommandObserver ;
1919use PHPUnit \Framework \Attributes \DataProvider ;
20+ use ReflectionClass ;
2021use TypeError ;
2122
2223use function array_filter ;
@@ -405,6 +406,16 @@ public function testWithOptionsInheritsOptions(): void
405406 foreach ($ collectionOptions as $ key => $ value ) {
406407 $ this ->assertSame ($ value , $ debug [$ key ]);
407408 }
409+
410+ // autoEncryptionEnabled is an internal option not reported via debug info
411+ $ collection = new Collection ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), ['autoEncryptionEnabled ' => true ]);
412+ $ clone = $ collection ->withOptions ();
413+
414+ $ rc = new ReflectionClass ($ clone );
415+ $ rp = $ rc ->getProperty ('autoEncryptionEnabled ' );
416+ $ rp ->setAccessible (true );
417+
418+ $ this ->assertSame (true , $ rp ->getValue ($ clone ));
408419 }
409420
410421 public function testWithOptionsPassesOptions (): void
@@ -424,6 +435,15 @@ public function testWithOptionsPassesOptions(): void
424435 foreach ($ collectionOptions as $ key => $ value ) {
425436 $ this ->assertSame ($ value , $ debug [$ key ]);
426437 }
438+
439+ // autoEncryptionEnabled is an internal option not reported via debug info
440+ $ clone = $ this ->collection ->withOptions (['autoEncryptionEnabled ' => true ]);
441+
442+ $ rc = new ReflectionClass ($ clone );
443+ $ rp = $ rc ->getProperty ('autoEncryptionEnabled ' );
444+ $ rp ->setAccessible (true );
445+
446+ $ this ->assertSame (true , $ rp ->getValue ($ clone ));
427447 }
428448
429449 public static function collectionMethodClosures ()
0 commit comments