From eec5206077efdc2512f9d63c421cb3803f3d6dc0 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Wed, 29 Nov 2017 10:41:34 -0500 Subject: [PATCH] Version: add api endpoint --- lib/Gitlab/Api/Version.php | 9 +++++++++ lib/Gitlab/Client.php | 12 ++++++++++++ test/Gitlab/Tests/Api/VersionTest.php | 26 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 lib/Gitlab/Api/Version.php create mode 100644 test/Gitlab/Tests/Api/VersionTest.php diff --git a/lib/Gitlab/Api/Version.php b/lib/Gitlab/Api/Version.php new file mode 100644 index 000000000..59a58104b --- /dev/null +++ b/lib/Gitlab/Api/Version.php @@ -0,0 +1,9 @@ +get('version'); + } +} diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index 08679e011..a8d593571 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -37,6 +37,7 @@ * @property-read \Gitlab\Api\Users $users * @property-read \Gitlab\Api\Keys $keys * @property-read \Gitlab\Api\Tags $tags + * @property-read \Gitlab\Api\Version $version */ class Client { @@ -245,6 +246,14 @@ public function tags() return new Api\Tags($this); } + /** + * @return Api\Version + */ + public function version() + { + return new Api\Version($this); + } + /** * @param string $name * @@ -305,6 +314,9 @@ public function api($name) case 'tags': return $this->tags(); + case 'version': + return $this->version(); + default: throw new InvalidArgumentException('Invalid endpoint: "'.$name.'"'); } diff --git a/test/Gitlab/Tests/Api/VersionTest.php b/test/Gitlab/Tests/Api/VersionTest.php new file mode 100644 index 000000000..c85a2414e --- /dev/null +++ b/test/Gitlab/Tests/Api/VersionTest.php @@ -0,0 +1,26 @@ + "8.13.0-pre", + "revision" => "4e963fe", + ); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('version') + ->will($this->returnValue($expectedArray)); + $this->assertEquals($expectedArray, $api->show()); + } + protected function getApiClass() + { + return 'Gitlab\Api\Version'; + } +}