ConnectionTest.php 796 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 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

use Jenssegers\Mongodb\Connection;

class ConnectionTest extends PHPUnit_Framework_TestCase {

	private $collection;
	private $connection;

	public function setUp()
	{
		$config = array(
			'host'     => 'localhost',
			'database' => 'unittest'
		);

		$this->connection = new Connection($config);
		$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());
	}

}