connect() public method

Connects to the Mongo server. Matches up parameters from the constructor to create a Mongo database connection.
See also: lithium\data\source\MongoDb::__construct()
public connect ( ) : boolean
return boolean Returns `true` the connection attempt was successful, otherwise `false`.
Beispiel #1
0
 public function testGoodConnectionBadDatabase()
 {
     $db = new MongoDb(array('database' => null, 'autoConnnect' => false));
     $this->assertException('Could not connect to the database.', function () use($db) {
         $db->connect();
     });
 }
 public function testBadConnection()
 {
     $db = new MongoDb(array('host' => null, 'autoConnect' => false));
     $this->expectException('Could not connect to the database.');
     $this->assertFalse($db->connect());
     $this->assertTrue($db->disconnect());
 }
Beispiel #3
0
 public function testGoodConnectionGoodDatabase()
 {
     $db = new MongoDb(array('autoConnect' => false) + $this->_testConfig);
     $this->assertTrue($db->connect());
 }