Skip to content

Commit

Permalink
Implement Connection::getServerVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jul 15, 2024
1 parent f654b83 commit 0117d7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ public function __call($method, $parameters)
return $this->db->$method(...$parameters);
}

public function getServerVersion(): string
{
return $this->db->command(['buildInfo' => 1])->toArray()[0]['version'];
}

private static function getVersion(): string
{
return self::$version ?? self::lookupVersion();
Expand Down
6 changes: 6 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,10 @@ public function testPingMethod()
$instance = new Connection($config);
$instance->ping();
}

public function testServerVersion()
{
$version = DB::connection('mongodb')->getServerVersion();
$this->assertIsString($version);
}
}

0 comments on commit 0117d7a

Please sign in to comment.