File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
tests/Doctrine/ODM/MongoDB/Tests/Functional Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 99use Doctrine \ODM \MongoDB \Tests \BaseTestCase ;
1010use Documents \CmsArticle ;
1111use MongoDB \Driver \BulkWrite ;
12+ use MongoDB \Driver \WriteConcern ;
1213use PHPUnit \Framework \Attributes \Group ;
1314use PHPUnit \Framework \Attributes \TestWith ;
1415
16+ use function bin2hex ;
1517use function hrtime ;
18+ use function random_bytes ;
1619
1720#[Group('atlas ' )]
1821class SchemaManagerWaitForSearchIndexesTest extends BaseTestCase
1922{
23+ protected function setUp (): void
24+ {
25+ parent ::setUp ();
26+
27+ // Randomize the collection name to avoid collisions when search indexes
28+ // are created or dropped asynchronously
29+ $ this ->dm ->getClassMetadata (CmsArticle::class)
30+ ->setCollection ('articles_ ' . bin2hex (random_bytes (4 )));
31+ }
32+
2033 #[TestWith([0 ])]
2134 #[TestWith([50_000 ])]
2235 public function testWait (int $ nbDocuments ): void
@@ -32,7 +45,11 @@ public function testWait(int $nbDocuments): void
3245 $ bulk ->insert (['topic ' => 'topic ' . $ i , 'title ' => 'title ' . $ i , 'text ' => 'text ' . $ i ]);
3346 }
3447
35- $ collection ->getManager ()->executeBulkWrite ($ collection ->getNamespace (), $ bulk );
48+ $ collection ->getManager ()->executeBulkWrite (
49+ $ collection ->getNamespace (),
50+ $ bulk ,
51+ ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )],
52+ );
3653 }
3754
3855 // The index must be created after data insertion, so the index status is not immediately "READY"
You can’t perform that action at this time.
0 commit comments