Skip to content

Commit 95d84fb

Browse files
authored
PHPLIB-682: Add test for Database::dropCollection() (#847)
1 parent 722679f commit 95d84fb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tests/Collection/CollectionFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testDrop(): void
264264

265265
$commandResult = $this->collection->drop();
266266
$this->assertCommandSucceeded($commandResult);
267-
$this->assertCollectionCount($this->getNamespace(), 0);
267+
$this->assertCollectionDoesNotExist($this->getCollectionName());
268268
}
269269

270270
/**

tests/Database/DatabaseFunctionalTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ public function testDrop(): void
159159
$this->assertCollectionCount($this->getNamespace(), 0);
160160
}
161161

162+
public function testDropCollection(): void
163+
{
164+
$bulkWrite = new BulkWrite();
165+
$bulkWrite->insert(['x' => 1]);
166+
167+
$writeResult = $this->manager->executeBulkWrite($this->getNamespace(), $bulkWrite);
168+
$this->assertEquals(1, $writeResult->getInsertedCount());
169+
170+
$commandResult = $this->database->dropCollection($this->getCollectionName());
171+
$this->assertCommandSucceeded($commandResult);
172+
$this->assertCollectionDoesNotExist($this->getCollectionName());
173+
}
174+
162175
public function testGetSelectsCollectionAndInheritsOptions(): void
163176
{
164177
$databaseOptions = ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)];

0 commit comments

Comments
 (0)