@@ -20,6 +20,9 @@ public function testDb()
2020 {
2121 $ connection = DB ::connection ('mongodb ' );
2222 $ this ->assertInstanceOf ('MongoDB ' , $ connection ->getMongoDB ());
23+
24+ $ connection = DB ::connection ('mongodb ' );
25+ $ this ->assertInstanceOf ('MongoClient ' , $ connection ->getMongoClient ());
2326 }
2427
2528 public function testCollection ()
@@ -81,4 +84,33 @@ public function testSchemaBuilder()
8184 $ this ->assertInstanceOf ('Jenssegers\Mongodb\Schema\Builder ' , $ schema );
8285 }
8386
87+ public function testDriverName ()
88+ {
89+ $ driver = DB ::connection ('mongodb ' )->getDriverName ();
90+ $ this ->assertEquals ('mongodb ' , $ driver );
91+ }
92+
93+ public function testAuth ()
94+ {
95+ Config::set ('database.connections.mongodb.username ' , 'foo ' );
96+ Config::set ('database.connections.mongodb.password ' , 'bar ' );
97+ $ host = Config::get ('database.connections.mongodb.host ' );
98+ $ port = Config::get ('database.connections.mongodb.port ' , 27017 );
99+ $ database = Config::get ('database.connections.mongodb.database ' );
100+
101+ $ this ->setExpectedException ('MongoConnectionException ' , "Failed to connect to: $ host: $ port: Authentication failed on database ' $ database' with username 'foo': auth fails " );
102+ $ connection = DB ::connection ('mongodb ' );
103+ }
104+
105+ public function testCustomPort ()
106+ {
107+ $ port = 27000 ;
108+ Config::set ('database.connections.mongodb.port ' , $ port );
109+ $ host = Config::get ('database.connections.mongodb.host ' );
110+ $ database = Config::get ('database.connections.mongodb.database ' );
111+
112+ $ this ->setExpectedException ('MongoConnectionException ' , "Failed to connect to: $ host: $ port: Connection refused " );
113+ $ connection = DB ::connection ('mongodb ' );
114+ }
115+
84116}
0 commit comments