Skip to content

Commit cc97844

Browse files
committed
Remove Atlas from the exception name, as this is no longer specific to Atlas, thanks to Community Search
1 parent ccd5be1 commit cc97844

File tree

9 files changed

+19
-21
lines changed

9 files changed

+19
-21
lines changed

src/Exception/AtlasSearchNotSupportedException.php renamed to src/Exception/SearchNotSupportedException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use MongoDB\Driver\Exception\ServerException;
66
use Throwable;
77

8-
final class AtlasSearchNotSupportedException extends ServerException
8+
final class SearchNotSupportedException extends ServerException
99
{
1010
/** @internal */
1111
public static function create(ServerException $e): self
@@ -16,7 +16,7 @@ public static function create(ServerException $e): self
1616
}
1717

1818
/** @internal */
19-
public static function isAtlasSearchNotSupportedError(Throwable $e): bool
19+
public static function isSearchNotSupportedError(Throwable $e): bool
2020
{
2121
if (! $e instanceof ServerException) {
2222
return false;

src/Operation/Aggregate.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use MongoDB\Driver\Server;
2828
use MongoDB\Driver\Session;
2929
use MongoDB\Driver\WriteConcern;
30-
use MongoDB\Exception\AtlasSearchNotSupportedException;
30+
use MongoDB\Exception\SearchNotSupportedException;
3131
use MongoDB\Exception\InvalidArgumentException;
3232
use MongoDB\Exception\UnexpectedValueException;
3333
use MongoDB\Exception\UnsupportedException;
@@ -238,8 +238,8 @@ public function execute(Server $server): CursorInterface
238238
try {
239239
$cursor = $this->executeCommand($server, $command);
240240
} catch (ServerException $exception) {
241-
if (AtlasSearchNotSupportedException::isAtlasSearchNotSupportedError($exception)) {
242-
throw AtlasSearchNotSupportedException::create($exception);
241+
if (SearchNotSupportedException::isSearchNotSupportedError($exception)) {
242+
throw SearchNotSupportedException::create($exception);
243243
}
244244

245245
throw $exception;

src/Operation/CreateSearchIndexes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2222
use MongoDB\Driver\Exception\ServerException;
2323
use MongoDB\Driver\Server;
24-
use MongoDB\Exception\AtlasSearchNotSupportedException;
24+
use MongoDB\Exception\SearchNotSupportedException;
2525
use MongoDB\Exception\InvalidArgumentException;
2626
use MongoDB\Exception\UnsupportedException;
2727
use MongoDB\Model\SearchIndexInput;
@@ -88,8 +88,8 @@ public function execute(Server $server): array
8888
try {
8989
$cursor = $server->executeCommand($this->databaseName, new Command($cmd));
9090
} catch (ServerException $exception) {
91-
if (AtlasSearchNotSupportedException::isAtlasSearchNotSupportedError($exception)) {
92-
throw AtlasSearchNotSupportedException::create($exception);
91+
if (SearchNotSupportedException::isSearchNotSupportedError($exception)) {
92+
throw SearchNotSupportedException::create($exception);
9393
}
9494

9595
throw $exception;

tests/Collection/CollectionFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ public function testMethodInTransactionWithReadConcernOption($method): void
783783

784784
public function testListSearchIndexesInheritTypeMap(): void
785785
{
786-
$this->skipIfAtlasSearchIndexIsNotSupported();
786+
$this->skipIfSearchIndexIsNotSupported();
787787

788788
$collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName(), ['typeMap' => ['root' => 'array']]);
789789

tests/ExamplesTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,7 @@ public static function provideExamples(): Generator
229229
#[Group('atlas')]
230230
public function testAtlasSearch(): void
231231
{
232-
if (! $this->isAtlas()) {
233-
$this->markTestSkipped('Atlas Search examples are only supported on MongoDB Atlas');
234-
}
232+
$this->skipIfSearchIndexIsNotSupported();
235233

236234
$this->skipIfServerVersion('<', '7.0', 'Atlas Search examples require MongoDB 7.0 or later');
237235

tests/Exception/SearchNotSupportedExceptionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use MongoDB\Collection;
66
use MongoDB\Driver\Command;
77
use MongoDB\Driver\Exception\ServerException;
8-
use MongoDB\Exception\AtlasSearchNotSupportedException;
8+
use MongoDB\Exception\SearchNotSupportedException;
99
use MongoDB\Tests\Collection\FunctionalTestCase;
1010
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
1111

12-
class AtlasSearchNotSupportedExceptionTest extends FunctionalTestCase
12+
class SearchNotSupportedExceptionTest extends FunctionalTestCase
1313
{
1414
#[DoesNotPerformAssertions]
1515
public function testListSearchIndexesNotSupportedException(): void
@@ -18,7 +18,7 @@ public function testListSearchIndexesNotSupportedException(): void
1818

1919
try {
2020
$collection->listSearchIndexes();
21-
} catch (AtlasSearchNotSupportedException) {
21+
} catch (SearchNotSupportedException) {
2222
// If an exception is thrown because Atlas Search is not supported,
2323
// then the test is successful because it has the correct exception class.
2424
}
@@ -31,7 +31,7 @@ public function testCreateSearchIndexNotSupportedException(): void
3131

3232
try {
3333
$collection->createSearchIndex(['mappings' => ['dynamic' => false]], ['name' => 'test-search-index']);
34-
} catch (AtlasSearchNotSupportedException) {
34+
} catch (SearchNotSupportedException) {
3535
// If an exception is thrown because Atlas Search is not supported,
3636
// then the test is successful because it has the correct exception class.
3737
}
@@ -47,7 +47,7 @@ public function testOtherStageNotFound(): void
4747
]);
4848
self::fail('Expected ServerException was not thrown');
4949
} catch (ServerException $exception) {
50-
self::assertNotInstanceOf(AtlasSearchNotSupportedException::class, $exception, $exception);
50+
self::assertNotInstanceOf(SearchNotSupportedException::class, $exception, $exception);
5151
}
5252
}
5353

@@ -57,7 +57,7 @@ public function testOtherCommandNotFound(): void
5757
$this->manager->executeCommand($this->getDatabaseName(), new Command(['nonExistingCommand' => 1]));
5858
self::fail('Expected ServerException was not thrown');
5959
} catch (ServerException $exception) {
60-
self::assertFalse(AtlasSearchNotSupportedException::isAtlasSearchNotSupportedError($exception));
60+
self::assertFalse(SearchNotSupportedException::isSearchNotSupportedError($exception));
6161
}
6262
}
6363
}

tests/FunctionalTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ protected function skipIfServerVersion(string $operator, string $version, ?strin
432432
}
433433
}
434434

435-
protected function skipIfAtlasSearchIndexIsNotSupported(): void
435+
protected function skipIfSearchIndexIsNotSupported(): void
436436
{
437437
try {
438438
$this->manager->executeReadCommand($this->getDatabaseName(), new Command([

tests/SpecTests/SearchIndexSpecTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function setUp(): void
3131
{
3232
parent::setUp();
3333

34-
$this->skipIfAtlasSearchIndexIsNotSupported();
34+
$this->skipIfSearchIndexIsNotSupported();
3535
}
3636

3737
/**

tests/UnifiedSpecTests/UnifiedSpecTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public static function provideFailingTests(): Generator
366366
#[DataProvider('provideIndexManagementTests')]
367367
public function testIndexManagement(UnifiedTestCase $test): void
368368
{
369-
$this->skipIfAtlasSearchIndexIsNotSupported();
369+
$this->skipIfSearchIndexIsNotSupported();
370370

371371
if (! self::isEnterprise()) {
372372
self::markTestSkipped('Specific Atlas error messages are only available on Enterprise server');

0 commit comments

Comments
 (0)