Skip to content

Commit eec5206

Browse files
committed
Version: add api endpoint
1 parent 84ce65a commit eec5206

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

lib/Gitlab/Api/Version.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php namespace Gitlab\Api;
2+
3+
class Version extends AbstractApi
4+
{
5+
public function show()
6+
{
7+
return $this->get('version');
8+
}
9+
}

lib/Gitlab/Client.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @property-read \Gitlab\Api\Users $users
3838
* @property-read \Gitlab\Api\Keys $keys
3939
* @property-read \Gitlab\Api\Tags $tags
40+
* @property-read \Gitlab\Api\Version $version
4041
*/
4142
class Client
4243
{
@@ -245,6 +246,14 @@ public function tags()
245246
return new Api\Tags($this);
246247
}
247248

249+
/**
250+
* @return Api\Version
251+
*/
252+
public function version()
253+
{
254+
return new Api\Version($this);
255+
}
256+
248257
/**
249258
* @param string $name
250259
*
@@ -305,6 +314,9 @@ public function api($name)
305314
case 'tags':
306315
return $this->tags();
307316

317+
case 'version':
318+
return $this->version();
319+
308320
default:
309321
throw new InvalidArgumentException('Invalid endpoint: "'.$name.'"');
310322
}

test/Gitlab/Tests/Api/VersionTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php namespace Gitlab\Tests\Api;
2+
3+
class VersionTest extends TestCase
4+
{
5+
/**
6+
* @test
7+
*/
8+
public function shouldShowVersion()
9+
{
10+
$expectedArray = array(
11+
"version" => "8.13.0-pre",
12+
"revision" => "4e963fe",
13+
);
14+
15+
$api = $this->getApiMock();
16+
$api->expects($this->once())
17+
->method('get')
18+
->with('version')
19+
->will($this->returnValue($expectedArray));
20+
$this->assertEquals($expectedArray, $api->show());
21+
}
22+
protected function getApiClass()
23+
{
24+
return 'Gitlab\Api\Version';
25+
}
26+
}

0 commit comments

Comments
 (0)