Skip to content

Commit 4aad357

Browse files
committed
Add testRenameCollection()
1 parent edf7c95 commit 4aad357

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ public function renameCollection($newCollectionName, array $options = [])
10281028
$options['writeConcern'] = $this->writeConcern;
10291029
}
10301030

1031-
$operation = new RenameCollection($this->databaseName, $this->collectionName, $newCollectionName, $options);
1031+
$operation = new RenameCollection('admin', $this->collectionName, $newCollectionName, $options);
10321032

10331033
return $operation->execute($server);
10341034
}

tests/Collection/CollectionFunctionalTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,16 @@ public function testFindWithinTransaction(): void
332332
}
333333
}
334334

335-
public function testWithOptionsInheritsOptions(): void
335+
public function testRenameCollection()
336+
{
337+
$writeResult = $this->collection->insertOne(['x' => 1]);
338+
$this->assertEquals(1, $writeResult->getInsertedCount());
339+
340+
$commandResult = $this->collection->renameCollection($this->getCollectionName() . 'renamed');
341+
$this->assertCommandSucceeded($commandResult);
342+
}
343+
344+
public function testWithOptionsInheritsOptions()
336345
{
337346
$collectionOptions = [
338347
'readConcern' => new ReadConcern(ReadConcern::LOCAL),

0 commit comments

Comments
 (0)