@@ -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