Skip to content

Commit 88d74b8

Browse files
committed
PHPLIB-518: Don't assert error codes for pre-3.2 servers in renameCollection tests
1 parent 3a0bef4 commit 88d74b8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/Operation/RenameCollectionFunctionalTest.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ public function testRenameCollectionExistingTarget(): void
107107

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

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

@@ -124,7 +127,13 @@ public function testRenameCollectionExistingTarget(): void
124127
public function testRenameNonexistentCollection(): void
125128
{
126129
$this->expectException(CommandException::class);
127-
$this->expectExceptionCode(self::$errorCodeNamespaceNotFound);
130+
131+
/* Note: pre-3.2 server versions omit an error code. libmongoc will
132+
* substitute MONGOC_ERROR_QUERY_FAILURE in _mongoc_cmd_check_ok */
133+
if (version_compare($this->getServerVersion(), '3.2.0', '>=')) {
134+
$this->expectExceptionCode(self::$errorCodeNamespaceNotFound);
135+
}
136+
128137
$operation = new RenameCollection(
129138
$this->getDatabaseName(),
130139
$this->getCollectionName(),

0 commit comments

Comments
 (0)