|
13 | 13 | use MongoDB\Exception\UnsupportedException;
|
14 | 14 | use MongoDB\MapReduceResult;
|
15 | 15 | use MongoDB\Operation\Count;
|
| 16 | +use MongoDB\Operation\DropCollection; |
| 17 | +use MongoDB\Operation\FindOne; |
16 | 18 | use MongoDB\Tests\CommandObserver;
|
17 | 19 |
|
18 | 20 | use function array_filter;
|
@@ -332,13 +334,21 @@ public function testFindWithinTransaction(): void
|
332 | 334 | }
|
333 | 335 | }
|
334 | 336 |
|
335 |
| - public function testRenameCollection(): void |
| 337 | + public function testRename(): void |
336 | 338 | {
|
337 |
| - $writeResult = $this->collection->insertOne(['x' => 1]); |
| 339 | + $renamedCollection = $this->getCollectionName() . '.renamed'; |
| 340 | + $operation = new DropCollection($this->getDatabaseName(), $renamedCollection); |
| 341 | + $operation->execute($this->getPrimaryServer()); |
| 342 | + |
| 343 | + $writeResult = $this->collection->insertOne(['_id' => 1, 'x' => 'foo']); |
338 | 344 | $this->assertEquals(1, $writeResult->getInsertedCount());
|
339 | 345 |
|
340 |
| - $commandResult = $this->collection->renameCollection($this->getCollectionName() . 'renamed'); |
| 346 | + $commandResult = $this->collection->rename($this->getDatabaseName() . '.' . $renamedCollection); |
341 | 347 | $this->assertCommandSucceeded($commandResult);
|
| 348 | + |
| 349 | + $operation = new FindOne($this->getDatabaseName(), $renamedCollection, []); |
| 350 | + $cursor = $operation->execute($this->getPrimaryServer()); |
| 351 | + $this->assertSameDocument(['_id' => 1, 'x' => 'foo'], $cursor); |
342 | 352 | }
|
343 | 353 |
|
344 | 354 | public function testWithOptionsInheritsOptions(): void
|
|
0 commit comments