Skip to content

Commit 7474433

Browse files
jdecoolm1guelpf
authored andcommitted
Add method to show group variable details
1 parent ce49d55 commit 7474433

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/Gitlab/Api/Groups.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ public function variables($group_id, array $parameters = [])
231231
return $this->get($this->getGroupPath($group_id, 'variables'), $resolver->resolve($parameters));
232232
}
233233

234+
/**
235+
* @param int $group_id
236+
* @param string $key
237+
*
238+
* @return mixed
239+
*/
240+
public function variable($group_id, $key)
241+
{
242+
return $this->get($this->getGroupPath($group_id, 'variables/'.$this->encodePath($key)));
243+
}
244+
234245
private function getGroupSearchResolver()
235246
{
236247
$resolver = $this->createOptionsResolver();

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ public function shouldGetVariables()
311311
$this->assertEquals($expectedArray, $api->variables(1));
312312
}
313313

314+
/**
315+
* @test
316+
*/
317+
public function shouldGetVariable()
318+
{
319+
$expectedArray = array('key' => 'ftp_username', 'value' => 'ftp');
320+
321+
$api = $this->getApiMock();
322+
$api->expects($this->once())
323+
->method('get')
324+
->with('groups/1/variables/ftp_username')
325+
->will($this->returnValue($expectedArray))
326+
;
327+
328+
$this->assertEquals($expectedArray, $api->variable(1, 'ftp_username'));
329+
}
330+
314331
protected function getApiClass()
315332
{
316333
return 'Gitlab\Api\Groups';

0 commit comments

Comments
 (0)