@@ -100,33 +100,27 @@ public function testAuth()
100
100
{
101
101
Config::set ('database.connections.mongodb.username ' , 'foo ' );
102
102
Config::set ('database.connections.mongodb.password ' , 'bar ' );
103
- $ host = Config::get ('database.connections.mongodb.host ' );
104
- $ port = Config::get ('database.connections.mongodb.port ' , 27017 );
105
- $ database = Config::get ('database.connections.mongodb.database ' );
103
+ Config::set ('database.connections.mongodb.options.database ' , 'custom ' );
106
104
107
- // $this->setExpectedExceptionRegExp('MongoConnectionException', "/Failed to connect to: $host:$port: Authentication failed on database '$database' with username 'foo': auth fail/");
108
105
$ connection = DB ::connection ('mongodb ' );
106
+ $ this ->assertEquals ('mongodb://127.0.0.1/custom ' , (string ) $ connection ->getMongoClient ());
109
107
}
110
108
111
- public function testCustomPort ()
109
+ public function testCustomHostAndPort ()
112
110
{
113
- $ port = 27000 ;
114
- Config::set ('database.connections.mongodb.port ' , $ port );
115
- $ host = Config::get ('database.connections.mongodb.host ' );
116
- $ database = Config::get ('database.connections.mongodb.database ' );
111
+ Config::set ('database.connections.mongodb.host ' , 'db1 ' );
112
+ Config::set ('database.connections.mongodb.port ' , 27000 );
117
113
118
- // $this->setExpectedException('MongoConnectionException', "Failed to connect to: $host:$port: Connection refused");
119
114
$ connection = DB ::connection ('mongodb ' );
115
+ $ this ->assertEquals ("mongodb://db1:27000 " , (string ) $ connection ->getMongoClient ());
120
116
}
121
117
122
118
public function testHostWithPorts ()
123
119
{
124
- $ hosts = ['localhost:27001 ' , 'localhost:27002 ' ];
125
120
Config::set ('database.connections.mongodb.port ' , 27000 );
126
- Config::set ('database.connections.mongodb.host ' , ['localhost:27001 ' , 'localhost:27002 ' ]);
127
- $ database = Config::get ('database.connections.mongodb.database ' );
121
+ Config::set ('database.connections.mongodb.host ' , ['db1:27001 ' , 'db2:27002 ' , 'db3:27000 ' ]);
128
122
129
- // $this->setExpectedException('MongoConnectionException', "Failed to connect to: " . $hosts[0] . ": Connection refused; Failed to connect to: " . $hosts[1] . ": Connection refused");
130
123
$ connection = DB ::connection ('mongodb ' );
124
+ $ this ->assertEquals ('mongodb://db1:27001,db2:27002,db3:27000 ' , (string ) $ connection ->getMongoClient ());
131
125
}
132
126
}
0 commit comments