Commit da4fdf19 authored by Jeremy Mikola's avatar Jeremy Mikola

Setup Database object in DatabaseFunctionalTest

parent 28da2e1e
...@@ -10,13 +10,22 @@ use MongoDB\Database; ...@@ -10,13 +10,22 @@ use MongoDB\Database;
*/ */
class DatabaseFunctionalTest extends FunctionalTestCase class DatabaseFunctionalTest extends FunctionalTestCase
{ {
private $database;
public function setUp()
{
parent::setUp();
$this->database = new Database($this->manager, $this->getDatabaseName());
$this->database->drop();
}
public function testDrop() public function testDrop()
{ {
$writeResult = $this->manager->executeInsert($this->getNamespace(), array('x' => 1)); $writeResult = $this->manager->executeInsert($this->getNamespace(), array('x' => 1));
$this->assertEquals(1, $writeResult->getInsertedCount()); $this->assertEquals(1, $writeResult->getInsertedCount());
$database = new Database($this->manager, $this->getDatabaseName()); $commandResult = $this->database->drop();
$commandResult = $database->drop();
$this->assertCommandSucceeded($commandResult); $this->assertCommandSucceeded($commandResult);
$this->assertCollectionCount($this->getNamespace(), 0); $this->assertCollectionCount($this->getNamespace(), 0);
} }
...@@ -26,8 +35,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase ...@@ -26,8 +35,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
$writeResult = $this->manager->executeInsert($this->getNamespace(), array('x' => 1)); $writeResult = $this->manager->executeInsert($this->getNamespace(), array('x' => 1));
$this->assertEquals(1, $writeResult->getInsertedCount()); $this->assertEquals(1, $writeResult->getInsertedCount());
$database = new Database($this->manager, $this->getDatabaseName()); $commandResult = $this->database->dropCollection($this->getCollectionName());
$commandResult = $database->dropCollection($this->getCollectionName());
$this->assertCommandSucceeded($commandResult); $this->assertCommandSucceeded($commandResult);
$this->assertCollectionCount($this->getNamespace(), 0); $this->assertCollectionCount($this->getNamespace(), 0);
} }
......
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