@@ -20,6 +20,9 @@ public function testDb()
20
20
{
21
21
$ connection = DB ::connection ('mongodb ' );
22
22
$ this ->assertInstanceOf ('MongoDB ' , $ connection ->getMongoDB ());
23
+
24
+ $ connection = DB ::connection ('mongodb ' );
25
+ $ this ->assertInstanceOf ('MongoClient ' , $ connection ->getMongoClient ());
23
26
}
24
27
25
28
public function testCollection ()
@@ -81,4 +84,33 @@ public function testSchemaBuilder()
81
84
$ this ->assertInstanceOf ('Jenssegers\Mongodb\Schema\Builder ' , $ schema );
82
85
}
83
86
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
+
84
116
}
0 commit comments