|
7 | 7 | use MongoDB\Driver\Exception\ServerException; |
8 | 8 | use MongoDB\Exception\AtlasSearchNotSupportedException; |
9 | 9 | use MongoDB\Tests\Collection\FunctionalTestCase; |
| 10 | +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; |
10 | 11 |
|
11 | 12 | class AtlasSearchNotSupportedExceptionTest extends FunctionalTestCase |
12 | 13 | { |
| 14 | + #[DoesNotPerformAssertions] |
13 | 15 | public function testListSearchIndexesNotSupportedException(): void |
14 | 16 | { |
15 | | - if (self::isAtlas()) { |
16 | | - self::markTestSkipped('Atlas Search is supported on Atlas'); |
17 | | - } |
18 | | - |
19 | 17 | $collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName()); |
20 | 18 |
|
21 | | - $this->expectException(AtlasSearchNotSupportedException::class); |
22 | | - |
23 | | - $collection->listSearchIndexes(); |
| 19 | + try { |
| 20 | + $collection->listSearchIndexes(); |
| 21 | + } catch (AtlasSearchNotSupportedException) { |
| 22 | + // If an exception is thrown because Atlas Search is not supported, |
| 23 | + // then the test is successful because it has the correct exception class. |
| 24 | + } |
24 | 25 | } |
25 | 26 |
|
| 27 | + #[DoesNotPerformAssertions] |
26 | 28 | public function testCreateSearchIndexNotSupportedException(): void |
27 | 29 | { |
28 | | - if (self::isAtlas()) { |
29 | | - self::markTestSkipped('Atlas Search is supported on Atlas'); |
30 | | - } |
31 | | - |
32 | 30 | $collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName()); |
33 | 31 |
|
34 | | - $this->expectException(AtlasSearchNotSupportedException::class); |
35 | | - |
36 | | - $collection->createSearchIndex(['mappings' => ['dynamic' => false]], ['name' => 'test-search-index']); |
| 32 | + try { |
| 33 | + $collection->createSearchIndex(['mappings' => ['dynamic' => false]], ['name' => 'test-search-index']); |
| 34 | + } catch (AtlasSearchNotSupportedException) { |
| 35 | + // If an exception is thrown because Atlas Search is not supported, |
| 36 | + // then the test is successful because it has the correct exception class. |
| 37 | + } |
37 | 38 | } |
38 | 39 |
|
39 | 40 | public function testOtherStageNotFound(): void |
|
0 commit comments