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
<?php
require_once('vendor/autoload.php');
use Jenssegers\Mongodb\Connection;
class ConnectionTest extends PHPUnit_Framework_TestCase {
private $collection;
private $connection;
public function setUp()
{
include('tests/app.php');
$this->connection = new Connection($app['config']['database.connections']['mongodb']);
$this->collection = $this->connection->getCollection('unittest');
}
public function tearDown()
{
if ($this->collection)
{
$this->collection->drop();
}
}
public function testDb()
{
$db = $this->connection->getDb();
$this->assertInstanceOf('MongoDB', $db);
}
public function testCollection()
{
$this->assertInstanceOf('MongoCollection', $this->collection);
$this->assertEquals('unittest', $this->collection->getName());
}
}