2020use MongoDB \Tests \CommandObserver ;
2121use PHPUnit \Framework \Attributes \DataProvider ;
2222use PHPUnit \Framework \Attributes \Group ;
23+ use ReflectionClass ;
2324use TypeError ;
2425
2526use function array_filter ;
@@ -396,6 +397,16 @@ public function testWithOptionsInheritsOptions(): void
396397 foreach ($ collectionOptions as $ key => $ value ) {
397398 $ this ->assertSame ($ value , $ debug [$ key ]);
398399 }
400+
401+ // autoEncryptionEnabled is an internal option not reported via debug info
402+ $ collection = new Collection ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), ['autoEncryptionEnabled ' => true ]);
403+ $ clone = $ collection ->withOptions ();
404+
405+ $ rc = new ReflectionClass ($ clone );
406+ $ rp = $ rc ->getProperty ('autoEncryptionEnabled ' );
407+ $ rp ->setAccessible (true );
408+
409+ $ this ->assertSame (true , $ rp ->getValue ($ clone ));
399410 }
400411
401412 public function testWithOptionsPassesOptions (): void
@@ -415,6 +426,15 @@ public function testWithOptionsPassesOptions(): void
415426 foreach ($ collectionOptions as $ key => $ value ) {
416427 $ this ->assertSame ($ value , $ debug [$ key ]);
417428 }
429+
430+ // autoEncryptionEnabled is an internal option not reported via debug info
431+ $ clone = $ this ->collection ->withOptions (['autoEncryptionEnabled ' => true ]);
432+
433+ $ rc = new ReflectionClass ($ clone );
434+ $ rp = $ rc ->getProperty ('autoEncryptionEnabled ' );
435+ $ rp ->setAccessible (true );
436+
437+ $ this ->assertSame (true , $ rp ->getValue ($ clone ));
418438 }
419439
420440 #[Group('matrix-testing-exclude-server-4.4-driver-4.0 ' )]
0 commit comments