Skip to content

Commit 4484c6f

Browse files
o.trelinm1guelpf
authored andcommitted
List all members of a group or project including inherited members
1 parent 899e88d commit 4484c6f

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

lib/Gitlab/Api/Groups.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ public function transfer($group_id, $project_id)
8989
return $this->post('groups/'.$this->encodePath($group_id).'/projects/'.$this->encodePath($project_id));
9090
}
9191

92+
/**
93+
* @param integer $id
94+
* @param array $parameters
95+
* @return mixed
96+
*/
97+
public function allMembers($id, array $parameters = [])
98+
{
99+
$resolver = $this->createOptionsResolver();
100+
$resolver->setDefined('query');
101+
102+
return $this->get('groups/'.$this->encodePath($id).'/members/all', $resolver->resolve($parameters));
103+
}
104+
92105
/**
93106
* @param int $id
94107
* @param array $parameters (

lib/Gitlab/Api/Projects.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,19 @@ public function cancelPipeline($project_id, $pipeline_id)
261261
return $this->post($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id)).'/cancel');
262262
}
263263

264+
/**
265+
* @param integer $project_id
266+
* @param array $parameters
267+
* @return mixed
268+
*/
269+
public function allMembers($project_id, $parameters = [])
270+
{
271+
$resolver = $this->createOptionsResolver();
272+
$resolver->setDefined('query');
273+
274+
return $this->get('projects/'.$this->encodePath($project_id).'/members/all', $resolver->resolve($parameters));
275+
}
276+
264277
/**
265278
* @param int $project_id
266279
* @param array $parameters (

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,26 @@ public function shouldTransferProjectToGroup()
186186
$this->assertEquals($expectedBool, $api->transfer(1, 2));
187187
}
188188

189+
/**
190+
* @test
191+
*/
192+
public function shouldGetAllMembers()
193+
{
194+
$expectedArray = array(
195+
array('id' => 1, 'name' => 'Matt'),
196+
array('id' => 2, 'name' => 'Bob')
197+
);
198+
199+
$api = $this->getApiMock();
200+
$api->expects($this->once())
201+
->method('get')
202+
->with('groups/1/members/all')
203+
->will($this->returnValue($expectedArray))
204+
;
205+
206+
$this->assertEquals($expectedArray, $api->members(1));
207+
}
208+
189209
/**
190210
* @test
191211
*/

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,26 @@ public function shouldCancelPipeline()
560560
$this->assertEquals($expectedArray, $api->cancelPipeline(1, 6));
561561
}
562562

563+
/**
564+
* @test
565+
*/
566+
public function shouldGetAllMembers()
567+
{
568+
$expectedArray = array(
569+
array('id' => 1, 'name' => 'Matt'),
570+
array('id' => 2, 'name' => 'Bob')
571+
);
572+
573+
$api = $this->getApiMock();
574+
$api->expects($this->once())
575+
->method('get')
576+
->with('projects/1/members/all')
577+
->will($this->returnValue($expectedArray))
578+
;
579+
580+
$this->assertEquals($expectedArray, $api->members(1));
581+
}
582+
563583
/**
564584
* @test
565585
*/

0 commit comments

Comments
 (0)