Commit bd148eab authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #567

parents 798d510a 330161a2
......@@ -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 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
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 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
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);
}
}
......@@ -6,8 +6,8 @@ use MongoDB\Client;
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 @@ class DocumentationExamplesTest extends FunctionalTestCase
{
parent::setUp();
$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}
public function tearDown()
......@@ -30,8 +29,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
return;
}
$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}
public function testExample_1_2()
......@@ -1429,4 +1427,14 @@ class DocumentationExamplesTest extends FunctionalTestCase
{
$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());
}
}
......@@ -18,8 +18,7 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
{
parent::setUp();
$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}
public function tearDown()
......@@ -28,8 +27,7 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
return;
}
$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName());
$operation->execute($this->getPrimaryServer());
$this->dropCollection();
}
protected function createDefaultReadConcern()
......@@ -46,4 +44,14 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
{
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());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment