File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -20,23 +20,31 @@ public static function create(ServerException $e): self
2020 }
2121
2222 /** @internal */
23- public static function isSearchNotSupportedError (Throwable $ e ): bool
23+ public static function isSearchNotSupportedError (Throwable $ exception ): bool
2424 {
25- if (! $ e instanceof ServerException) {
25+ if (! $ exception instanceof ServerException) {
2626 return false ;
2727 }
2828
29- return match ($ e ->getCode ()) {
29+ return match ($ exception ->getCode ()) {
3030 // MongoDB 8: Using Atlas Search Database Commands and the $listSearchIndexes aggregation stage requires additional configuration.
3131 31082 => true ,
3232 // MongoDB 7: $listSearchIndexes stage is only allowed on MongoDB Atlas
3333 6047401 => true ,
3434 // MongoDB 7-ent: Search index commands are only supported with Atlas.
3535 115 => true ,
3636 // MongoDB 4 to 6, 7-community
37- 59 => 'no such command: \'createSearchIndexes \'' === $ e ->getMessage (),
37+ 59 => match ($ exception ->getMessage ()) {
38+ 'no such command: \'createSearchIndexes \'' => true ,
39+ 'no such command: \'updateSearchIndex \'' => true ,
40+ 'no such command: \'dropSearchIndex \'' => true ,
41+ default => false ,
42+ },
3843 // MongoDB 4 to 6
39- 40324 => 'Unrecognized pipeline stage name: \'$listSearchIndexes \'' === $ e ->getMessage (),
44+ 40324 => match ($ exception ->getMessage ()) {
45+ 'Unrecognized pipeline stage name: \'$listSearchIndexes \'' => true ,
46+ default => false ,
47+ },
4048 // Not an Atlas Search error
4149 default => false ,
4250 };
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class SearchNotSupportedExceptionTest extends FunctionalTestCase
1313 #[DoesNotPerformAssertions]
1414 public function testListSearchIndexesNotSupportedException (): void
1515 {
16- $ collection = $ this ->createCollection ($ this ->getDatabaseName (), ' SearchNotSupportedException ' );
16+ $ collection = $ this ->createCollection ($ this ->getDatabaseName (), $ this -> getCollectionName () );
1717
1818 try {
1919 $ collection ->listSearchIndexes ();
@@ -24,9 +24,9 @@ public function testListSearchIndexesNotSupportedException(): void
2424 }
2525
2626 #[DoesNotPerformAssertions]
27- public function testCreateSearchIndexNotSupportedException (): void
27+ public function testSearchIndexManagementNotSupportedException (): void
2828 {
29- $ collection = $ this ->createCollection ($ this ->getDatabaseName (), ' SearchNotSupportedException ' );
29+ $ collection = $ this ->createCollection ($ this ->getDatabaseName (), $ this -> getCollectionName () );
3030
3131 try {
3232 $ collection ->createSearchIndex (['mappings ' => ['dynamic ' => false ]], ['name ' => 'test-search-index ' ]);
@@ -52,7 +52,7 @@ public function testCreateSearchIndexNotSupportedException(): void
5252
5353 public function testOtherStageNotFound (): void
5454 {
55- $ collection = $ this ->createCollection ($ this ->getDatabaseName (), ' SearchNotSupportedException ' );
55+ $ collection = $ this ->createCollection ($ this ->getDatabaseName (), $ this -> getCollectionName () );
5656
5757 try {
5858 $ collection ->aggregate ([
You can’t perform that action at this time.
0 commit comments