diff --git a/src/Jenssegers/Mongodb/Connection.php b/src/Jenssegers/Mongodb/Connection.php index ee05e8cbc..00afe127e 100644 --- a/src/Jenssegers/Mongodb/Connection.php +++ b/src/Jenssegers/Mongodb/Connection.php @@ -133,6 +133,16 @@ protected function createConnection($dsn, array $config, array $options) return new MongoClient($dsn, $options); } + /** + * Disconnect from the underlying MongoClient connection. + * + * @return void + */ + public function disconnect() + { + $this->connection->close(); + } + /** * Create a DSN string from a configuration. * diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 2cc6ca139..d8c0be685 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -15,7 +15,8 @@ public function testReconnect() $this->assertEquals(spl_object_hash($c1), spl_object_hash($c2)); $c1 = DB::connection('mongodb'); - $c2 = DB::reconnect('mongodb'); + DB::purge('mongodb'); + $c2 = DB::connection('mongodb'); $this->assertNotEquals(spl_object_hash($c1), spl_object_hash($c2)); }