1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace MongoDB\Tests\Database;
use MongoDB\Database;
/**
* Functional tests for the Database class.
*/
class DatabaseFunctionalTest extends FunctionalTestCase
{
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDatabaseValues
*/
public function testConstructorDatabaseNameArgument($databaseName)
{
// TODO: Move to unit test once ManagerInterface can be mocked (PHPC-378)
new Database($this->manager, $databaseName);
}
public function provideInvalidDatabaseValues()
{
return array(
array(null),
array(''),
);
}
public function testToString()
{
$this->assertEquals($this->getDatabaseName(), (string) $this->database);
}
public function getGetDatabaseName()
{
$this->assertEquals($this->getDatabaseName(), $this->database->getDatabaseName());
}
public function testDrop()
{
$writeResult = $this->manager->executeInsert($this->getNamespace(), array('x' => 1));
$this->assertEquals(1, $writeResult->getInsertedCount());
$commandResult = $this->database->drop();
$this->assertCommandSucceeded($commandResult);
$this->assertCollectionCount($this->getNamespace(), 0);
}
}