@@ -492,6 +492,25 @@ public function testUpdateDocumentSearchIndexesNotSupportedForClassWithoutSearch
492
492
$ this ->schemaManager ->updateDocumentSearchIndexes (CmsProduct::class);
493
493
}
494
494
495
+ public function testUpdateDocumentWhenSearchNotEnabled (): void
496
+ {
497
+ // Class has no search indexes, so if the server doesn't support them we assume everything is fine
498
+ $ collectionName = $ this ->dm ->getClassMetadata (CmsProduct::class)->getCollection ();
499
+ $ collection = $ this ->documentCollections [$ collectionName ];
500
+ $ collection
501
+ ->expects ($ this ->once ())
502
+ ->method ('listSearchIndexes ' )
503
+ ->willThrowException ($ this ->createSearchNotEnabledCommandException ());
504
+ $ collection
505
+ ->expects ($ this ->never ())
506
+ ->method ('dropSearchIndex ' );
507
+ $ collection
508
+ ->expects ($ this ->never ())
509
+ ->method ('updateSearchIndex ' );
510
+
511
+ $ this ->schemaManager ->updateDocumentSearchIndexes (CmsProduct::class);
512
+ }
513
+
495
514
public function testUpdateDocumentSearchIndexesNotSupportedForClassWithoutSearchIndexesOnOlderServers (): void
496
515
{
497
516
// Class has no search indexes, so if the server doesn't support them we assume everything is fine
@@ -1375,6 +1394,11 @@ private function createSearchIndexCommandException(): CommandException
1375
1394
return new CommandException ('PlanExecutor error during aggregation :: caused by :: Search index commands are only supported with Atlas. ' , 115 );
1376
1395
}
1377
1396
1397
+ private function createSearchNotEnabledCommandException (): CommandException
1398
+ {
1399
+ return new CommandException ('Using Atlas Search Database Commands and the $listSearchIndexes aggregation stage requires additional configuration. ' , 31082 );
1400
+ }
1401
+
1378
1402
private function createSearchIndexCommandExceptionForOlderServers (): CommandException
1379
1403
{
1380
1404
return new CommandException ('Unrecognized pipeline stage name: \'$listSearchIndexes \'' , 40234 );
0 commit comments