ConnectionTest.php 783 Bytes
Newer Older
Jens Segers's avatar
Jens Segers committed
1
<?php
Jens Segers's avatar
Jens Segers committed
2
require_once('vendor/autoload.php');
Jens Segers's avatar
Jens Segers committed
3 4 5 6 7 8 9 10 11 12

use Jenssegers\Mongodb\Connection;

class ConnectionTest extends PHPUnit_Framework_TestCase {

	private $collection;
	private $connection;

	public function setUp()
	{
13 14
		include('tests/app.php');
		$this->connection = new Connection($app['config']['database.connections']['mongodb']);
Jens Segers's avatar
Jens Segers committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
		$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());
	}

}