Skip to content

Commit

Permalink
Showing 3 changed files with 38 additions and 14 deletions.
18 changes: 13 additions & 5 deletions tests/Collection/FunctionalTestCase.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
namespace MongoDB\Tests\Collection;

use MongoDB\Collection;
use MongoDB\Operation\DropCollection;
use MongoDB\Driver\WriteConcern;
use MongoDB\Tests\FunctionalTestCase as BaseFunctionalTestCase;

/**
@@ -18,8 +18,8 @@ public function setUp()
parent::setUp();

$this->collection = new Collection($this->manager, $this->getDatabaseName(), $this->getCollectionName());
$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());

$this->dropCollection();
}

public function tearDown()
@@ -28,7 +28,15 @@ public function tearDown()
return;
}

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}

private function dropCollection()
{
$options = version_compare($this->getServerVersion(), '3.4.0', '>=')
? ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]
: [];

$this->collection->drop($options);
}
}
18 changes: 13 additions & 5 deletions tests/DocumentationExamplesTest.php
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
use MongoDB\Database;
use MongoDB\Driver\Cursor;
use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern;
use MongoDB\Operation\DropCollection;
use MongoDB\Operation\DropDatabase;

/**
* Documentation examples to be parsed for inclusion in the MongoDB manual.
@@ -20,8 +20,7 @@ public function setUp()
{
parent::setUp();

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}

public function tearDown()
@@ -30,8 +29,7 @@ public function tearDown()
return;
}

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}

public function testExample_1_2()
@@ -1429,4 +1427,14 @@ private function assertInventoryCount($count)
{
$this->assertCollectionCount($this->getDatabaseName() . '.' . $this->getCollectionName(), $count);
}

private function dropCollection()
{
$options = version_compare($this->getServerVersion(), '3.4.0', '>=')
? ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]
: [];

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName(), $options);
$operation->execute($this->getPrimaryServer());
}
}
16 changes: 12 additions & 4 deletions tests/Operation/FunctionalTestCase.php
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@ public function setUp()
{
parent::setUp();

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}

public function tearDown()
@@ -28,8 +27,7 @@ public function tearDown()
return;
}

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}

protected function createDefaultReadConcern()
@@ -46,4 +44,14 @@ protected function createSession()
{
return $this->manager->startSession();
}

private function dropCollection()
{
$options = version_compare($this->getServerVersion(), '3.4.0', '>=')
? ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]
: [];

$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName(), $options);
$operation->execute($this->getPrimaryServer());
}
}

0 comments on commit bd148ea

Please sign in to comment.