Skip to content

Commit

Permalink
PHPLIB-518: Don't assert error codes for pre-3.2 servers in renameCol…
Browse files Browse the repository at this point in the history
…lection tests
  • Loading branch information
jmikola committed Oct 20, 2021
1 parent 3a0bef4 commit 88d74b8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/Operation/RenameCollectionFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ public function testRenameCollectionExistingTarget(): void

$this->expectException(CommandException::class);

// mongos returns an inconsistent error code (see: SERVER-60632)
if (! $this->isShardedCluster()) {
/* TODO: mongos returns an inconsistent error code (see: SERVER-60632)
*
* Note: pre-3.2 server versions omit an error code. libmongoc will
* substitute MONGOC_ERROR_QUERY_FAILURE in _mongoc_cmd_check_ok. */
if (! $this->isShardedCluster() && version_compare($this->getServerVersion(), '3.2.0', '>=')) {
$this->expectExceptionCode(self::$errorCodeNamespaceExists);
}

Expand All @@ -124,7 +127,13 @@ public function testRenameCollectionExistingTarget(): void
public function testRenameNonexistentCollection(): void
{
$this->expectException(CommandException::class);
$this->expectExceptionCode(self::$errorCodeNamespaceNotFound);

/* Note: pre-3.2 server versions omit an error code. libmongoc will
* substitute MONGOC_ERROR_QUERY_FAILURE in _mongoc_cmd_check_ok */
if (version_compare($this->getServerVersion(), '3.2.0', '>=')) {
$this->expectExceptionCode(self::$errorCodeNamespaceNotFound);
}

$operation = new RenameCollection(
$this->getDatabaseName(),
$this->getCollectionName(),
Expand Down

0 comments on commit 88d74b8

Please sign in to comment.