@@ -161,11 +161,29 @@ public function testModifyCollection()
161161 $ createIndexes = new CreateIndexes ($ this ->getDatabaseName (), $ this ->getCollectionName (), $ indexes );
162162 $ createIndexes ->execute ($ this ->getPrimaryServer ());
163163
164- $ commandResult = $ this ->database ->modifyCollection ($ this ->getCollectionName (), ['index ' => ['keyPattern ' => ['lastAccess ' => 1 ], 'expireAfterSeconds ' => 1000 ]]);
165-
164+ $ commandResult = $ this ->database ->modifyCollection (
165+ $ this ->getCollectionName (),
166+ ['index ' => ['keyPattern ' => ['lastAccess ' => 1 ], 'expireAfterSeconds ' => 1000 ]],
167+ ['typeMap ' => ['root ' => 'array ' , 'document ' => 'array ' ]]
168+ );
166169 $ this ->assertCommandSucceeded ($ commandResult );
167- $ this ->assertSame (3 , $ commandResult ['expireAfterSeconds_old ' ]);
168- $ this ->assertSame (1000 , $ commandResult ['expireAfterSeconds_new ' ]);
170+
171+ $ commandResult = (array ) $ commandResult ;
172+
173+ if (array_key_exists ('raw ' , $ commandResult )) {
174+ /* Sharded environment, where we only assert if a shard had a successful update. For
175+ * non-primary shards that don't have chunks for the collection, the result contains a
176+ * "ns does not exist" error. */
177+ foreach ($ commandResult ['raw ' ] as $ shard ) {
178+ if (array_key_exists ('ok ' , $ shard ) && $ shard ['ok ' ] == 1 ) {
179+ $ this ->assertSame (3 , $ shard ['expireAfterSeconds_old ' ]);
180+ $ this ->assertSame (1000 , $ shard ['expireAfterSeconds_new ' ]);
181+ }
182+ }
183+ } else {
184+ $ this ->assertSame (3 , $ commandResult ['expireAfterSeconds_old ' ]);
185+ $ this ->assertSame (1000 , $ commandResult ['expireAfterSeconds_new ' ]);
186+ }
169187 }
170188
171189
0 commit comments