public function testBadConnection() { $db = new MongoDb(array('host' => null, 'autoConnect' => false)); $this->assertException('Could not connect to the database.', function () use($db) { $db->connect(); }); $this->assertTrue($db->disconnect()); }