Skip to content

Commit ce49d55

Browse files
jdecoolm1guelpf
authored andcommitted
Add method to list group variables
1 parent 65c5478 commit ce49d55

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/Gitlab/Api/Groups.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ public function subgroups($groupId, array $parameters = [])
218218
return $this->get('groups/'.$this->encodePath($groupId).'/subgroups', $resolver->resolve($parameters));
219219
}
220220

221+
/**
222+
* @param int $group_id
223+
* @param array $parameters
224+
*
225+
* @return mixed
226+
*/
227+
public function variables($group_id, array $parameters = [])
228+
{
229+
$resolver = $this->createOptionsResolver();
230+
231+
return $this->get($this->getGroupPath($group_id, 'variables'), $resolver->resolve($parameters));
232+
}
233+
221234
private function getGroupSearchResolver()
222235
{
223236
$resolver = $this->createOptionsResolver();

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,23 @@ public function shouldGetAllSubgroups()
294294
$this->assertEquals($expectedArray, $api->subgroups(1, ['page' => 1, 'per_page' => 10]));
295295
}
296296

297+
public function shouldGetVariables()
298+
{
299+
$expectedArray = array(
300+
array('key' => 'ftp_username', 'value' => 'ftp'),
301+
array('key' => 'ftp_password', 'value' => 'somepassword')
302+
);
303+
304+
$api = $this->getApiMock();
305+
$api->expects($this->once())
306+
->method('get')
307+
->with('groups/1/variables')
308+
->will($this->returnValue($expectedArray))
309+
;
310+
311+
$this->assertEquals($expectedArray, $api->variables(1));
312+
}
313+
297314
protected function getApiClass()
298315
{
299316
return 'Gitlab\Api\Groups';

0 commit comments

Comments
 (0)