22
33namespace Exception ;
44
5- use MongoDB \Collection ;
65use MongoDB \Driver \Command ;
76use MongoDB \Driver \Exception \ServerException ;
87use MongoDB \Exception \SearchNotSupportedException ;
98use MongoDB \Tests \Collection \FunctionalTestCase ;
9+ use PHPUnit \Framework \Attributes \Depends ;
1010use PHPUnit \Framework \Attributes \DoesNotPerformAssertions ;
1111
1212class SearchNotSupportedExceptionTest extends FunctionalTestCase
1313{
1414 #[DoesNotPerformAssertions]
1515 public function testListSearchIndexesNotSupportedException (): void
1616 {
17- $ collection = new Collection ( $ this ->manager , $ this ->getDatabaseName (), $ this -> getCollectionName () );
17+ $ collection = $ this ->createCollection ( $ this ->getDatabaseName (), ' SearchNotSupportedException ' );
1818
1919 try {
2020 $ collection ->listSearchIndexes ();
@@ -27,7 +27,7 @@ public function testListSearchIndexesNotSupportedException(): void
2727 #[DoesNotPerformAssertions]
2828 public function testCreateSearchIndexNotSupportedException (): void
2929 {
30- $ collection = new Collection ( $ this ->manager , $ this ->getDatabaseName (), $ this -> getCollectionName () );
30+ $ collection = $ this ->createCollection ( $ this ->getDatabaseName (), ' SearchNotSupportedException ' );
3131
3232 try {
3333 $ collection ->createSearchIndex (['mappings ' => ['dynamic ' => false ]], ['name ' => 'test-search-index ' ]);
@@ -37,9 +37,37 @@ public function testCreateSearchIndexNotSupportedException(): void
3737 }
3838 }
3939
40+ #[DoesNotPerformAssertions]
41+ #[Depends('testCreateSearchIndexNotSupportedException ' )]
42+ public function testUpdateSearchIndexNotSupportedException (): void
43+ {
44+ $ collection = $ this ->createCollection ($ this ->getDatabaseName (), 'SearchNotSupportedException ' );
45+
46+ try {
47+ $ collection ->updateSearchIndex ('test-search-index ' , ['mappings ' => ['dynamic ' => true ]]);
48+ } catch (SearchNotSupportedException ) {
49+ // If an exception is thrown because Atlas Search is not supported,
50+ // then the test is successful because it has the correct exception class.
51+ }
52+ }
53+
54+ #[DoesNotPerformAssertions]
55+ #[Depends('testUpdateSearchIndexNotSupportedException ' )]
56+ public function testDropSearchIndexNotSupportedException (): void
57+ {
58+ $ collection = $ this ->createCollection ($ this ->getDatabaseName (), 'SearchNotSupportedException ' );
59+
60+ try {
61+ $ collection ->dropSearchIndex ('test-search-index ' );
62+ } catch (SearchNotSupportedException ) {
63+ // If an exception is thrown because Atlas Search is not supported,
64+ // then the test is successful because it has the correct exception class.
65+ }
66+ }
67+
4068 public function testOtherStageNotFound (): void
4169 {
42- $ collection = new Collection ( $ this ->manager , $ this ->getDatabaseName (), $ this -> getCollectionName () );
70+ $ collection = $ this ->createCollection ( $ this ->getDatabaseName (), ' SearchNotSupportedException ' );
4371
4472 try {
4573 $ collection ->aggregate ([
0 commit comments