Skip to content

Commit

Permalink
Added getServerVersion to connection (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaravelFreelancerNL authored Nov 24, 2024
1 parent 2342c55 commit a642392
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,20 @@ public function threadCount()

return $this->arangoClient->monitor()->getCurrentConnections();
}

/**
* Get the server version for the connection.
*
* @return string
*/
public function getServerVersion(): string
{
if (!$this->arangoClient) {
return '';
}

$rawVersion = $this->arangoClient->admin()->getVersion();

return $rawVersion->version;
}
}
7 changes: 7 additions & 0 deletions tests/Database/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,10 @@
expect($connection->threadCount())->toBeInt();
expect($connection->threadCount())->toBeGreaterThan(-1);
});

test('getServerVersion', function () {
$connection = $this->connection;

expect($connection->getServerVersion())->toBeString();
expect($connection->getServerVersion())->toMatch('/^\d+\.\d+\.\d+$/i');
});

0 comments on commit a642392

Please sign in to comment.