Skip to content

Commit 2f878f5

Browse files
o.trelinm1guelpf
authored andcommitted
1 parent 69d46a9 commit 2f878f5

File tree

8 files changed

+141
-41
lines changed

8 files changed

+141
-41
lines changed

lib/Gitlab/Api/Groups.php

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function projects($id, array $parameters = [])
198198
}
199199

200200
/**
201-
* @param int $groupId
201+
* @param int $group_id
202202
* @param array $parameters (
203203
*
204204
* @var int[] $skip_groups Skip the group IDs passes.
@@ -211,17 +211,60 @@ public function projects($id, array $parameters = [])
211211
* )
212212
* @return mixed
213213
*/
214-
public function subgroups($groupId, array $parameters = [])
214+
public function subgroups($group_id, array $parameters = [])
215215
{
216216
$resolver = $this->getGroupSearchResolver();
217217

218-
return $this->get('groups/'.$this->encodePath($groupId).'/subgroups', $resolver->resolve($parameters));
218+
return $this->get('groups/'.$this->encodePath($group_id).'/subgroups', $resolver->resolve($parameters));
219+
}
220+
221+
/**
222+
* @param int $group_id
223+
* @param array $parameters
224+
* @return mixed
225+
*/
226+
public function labels($group_id, array $parameters = [])
227+
{
228+
$resolver = $this->createOptionsResolver();
229+
230+
return $this->get('groups/'.$this->encodePath($group_id). '/labels', $resolver->resolve($parameters));
231+
}
232+
233+
/**
234+
* @param int $group_id
235+
* @param array $params
236+
* @return mixed
237+
*/
238+
public function addLabel($group_id, array $params)
239+
{
240+
return $this->post('groups/'.$this->encodePath($group_id). '/labels', $params);
241+
}
242+
243+
/**
244+
* @param int $group_id
245+
* @param array $params
246+
* @return mixed
247+
*/
248+
public function updateLabel($group_id, array $params)
249+
{
250+
return $this->put('groups/'.$this->encodePath($group_id). '/labels', $params);
251+
}
252+
253+
/**
254+
* @param int $group_id
255+
* @param string $name
256+
* @return mixed
257+
*/
258+
public function removeLabel($group_id, $name)
259+
{
260+
return $this->delete('groups/'.$this->encodePath($group_id). '/labels', array(
261+
'name' => $name
262+
));
219263
}
220264

221265
/**
222266
* @param int $group_id
223267
* @param array $parameters
224-
*
225268
* @return mixed
226269
*/
227270
public function variables($group_id, array $parameters = [])
@@ -234,7 +277,6 @@ public function variables($group_id, array $parameters = [])
234277
/**
235278
* @param int $group_id
236279
* @param string $key
237-
*
238280
* @return mixed
239281
*/
240282
public function variable($group_id, $key)
@@ -247,7 +289,6 @@ public function variable($group_id, $key)
247289
* @param string $key
248290
* @param string $value
249291
* @param bool $protected
250-
*
251292
* @return mixed
252293
*/
253294
public function addVariable($group_id, $key, $value, $protected = null)
@@ -269,7 +310,6 @@ public function addVariable($group_id, $key, $value, $protected = null)
269310
* @param string $key
270311
* @param string $value
271312
* @param bool $protected
272-
*
273313
* @return mixed
274314
*/
275315
public function updateVariable($group_id, $key, $value, $protected = null)
@@ -288,7 +328,6 @@ public function updateVariable($group_id, $key, $value, $protected = null)
288328
/**
289329
* @param int $group_id
290330
* @param string $key
291-
*
292331
* @return mixed
293332
*/
294333
public function removeVariable($group_id, $key)

lib/Gitlab/Api/GroupsMilestones.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function update($group_id, $milestone_id, array $params)
6262
}
6363

6464
/**
65-
* @param int $project_id
65+
* @param int $group_id
6666
* @param int $milestone_id
6767
* @return mixed
6868
*/
@@ -71,7 +71,6 @@ public function remove($group_id, $milestone_id)
7171
return $this->delete($this->getGroupPath($group_id, 'milestones/'.$this->encodePath($milestone_id)));
7272
}
7373

74-
7574
/**
7675
* @param int $group_id
7776
* @param int $milestone_id

lib/Gitlab/Api/Issues.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ public function removeDiscussionNote($project_id, $issue_iid, $discussion_id, $n
260260
* @param int $project_id
261261
* @param int $issue_iid
262262
* @param string $duration
263+
* @return mixed
263264
*/
264265
public function setTimeEstimate($project_id, $issue_iid, $duration)
265266
{
@@ -269,6 +270,7 @@ public function setTimeEstimate($project_id, $issue_iid, $duration)
269270
/**
270271
* @param int $project_id
271272
* @param int $issue_iid
273+
* @return mixed
272274
*/
273275
public function resetTimeEstimate($project_id, $issue_iid)
274276
{
@@ -279,6 +281,7 @@ public function resetTimeEstimate($project_id, $issue_iid)
279281
* @param int $project_id
280282
* @param int $issue_iid
281283
* @param string $duration
284+
* @return mixed
282285
*/
283286
public function addSpentTime($project_id, $issue_iid, $duration)
284287
{
@@ -288,6 +291,7 @@ public function addSpentTime($project_id, $issue_iid, $duration)
288291
/**
289292
* @param int $project_id
290293
* @param int $issue_iid
294+
* @return mixed
291295
*/
292296
public function resetSpentTime($project_id, $issue_iid)
293297
{

lib/Gitlab/Api/MergeRequests.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ public function merge($project_id, $mr_id, $message = null)
155155
}
156156

157157
/**
158-
* @param int $project_id
159-
* @param int $mr_id
158+
* @param int $project_id
159+
* @param int $mr_id
160160
*
161161
* @return mixed
162162
*/
@@ -182,7 +182,6 @@ public function addNote($project_id, $mr_id, $note)
182182
* @param int $projectId
183183
* @param int $mrId
184184
* @param int $noteId
185-
*
186185
* @return mixed
187186
*/
188187
public function removeNote($projectId, $mrId, $noteId)
@@ -337,45 +336,41 @@ public function closesIssues($project_id, $mr_id)
337336

338337
/**
339338
* @param int $project_id
340-
* @param int $mr_id
341-
*
339+
* @param int $mr_iid
342340
* @return mixed
343341
*/
344-
public function approvals($project_id, $merge_request_iid)
342+
public function approvals($project_id, $mr_iid)
345343
{
346-
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/approvals'));
344+
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/approvals'));
347345
}
348346

349347
/**
350348
* @param int $project_id
351-
* @param int $mr_id
352-
*
349+
* @param int $mr_iid
353350
* @return mixed
354351
*/
355-
public function approve($project_id, $merge_request_iid)
352+
public function approve($project_id, $mr_iid)
356353
{
357-
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/approve'));
354+
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/approve'));
358355
}
359356

360357
/**
361358
* @param int $project_id
362-
* @param int $mr_id
363-
*
359+
* @param int $mr_iid
364360
* @return mixed
365361
*/
366-
public function unapprove($project_id, $merge_request_iid)
362+
public function unapprove($project_id, $mr_iid)
367363
{
368-
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/unapprove'));
364+
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/unapprove'));
369365
}
370366

371367
/**
372368
* @param int $project_id
373-
* @param int $merge_request_iid
374-
*
369+
* @param int $mr_iid
375370
* @return mixed
376371
*/
377-
public function awardEmoji($project_id, $merge_request_iid)
372+
public function awardEmoji($project_id, $mr_iid)
378373
{
379-
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/award_emoji'));
374+
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/award_emoji'));
380375
}
381376
}

lib/Gitlab/Api/Milestones.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public function remove($project_id, $milestone_id)
7171
return $this->delete($this->getProjectPath($project_id, 'milestones/'.$this->encodePath($milestone_id)));
7272
}
7373

74-
7574
/**
7675
* @param int $project_id
7776
* @param int $milestone_id

lib/Gitlab/Api/Projects.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ public function removeMember($project_id, $user_id)
373373
/**
374374
* @param int $project_id
375375
* @param array $parameters
376-
*
377376
* @return mixed
378377
*/
379378
public function hooks($project_id, array $parameters = [])
@@ -686,7 +685,6 @@ public function removeService($project_id, $service_name)
686685
/**
687686
* @param int $project_id
688687
* @param array $parameters
689-
*
690688
* @return mixed
691689
*/
692690
public function variables($project_id, array $parameters = [])
@@ -780,7 +778,6 @@ public function uploadFile($project_id, $file)
780778
/**
781779
* @param int $project_id
782780
* @param array $parameters
783-
*
784781
* @return mixed
785782
*/
786783
public function deployments($project_id, array $parameters = [])

lib/Gitlab/Api/Repositories.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ public function createTag($project_id, $name, $ref, $message = null)
107107
}
108108

109109
/**
110-
* @param int $project_id
110+
* @param int $project_id
111111
* @param string $tag_name
112112
* @param string $description
113-
*
114113
* @return mixed
115114
*/
116115
public function createRelease($project_id, $tag_name, $description)
@@ -123,10 +122,9 @@ public function createRelease($project_id, $tag_name, $description)
123122
}
124123

125124
/**
126-
* @param int $project_id
125+
* @param int $project_id
127126
* @param string $tag_name
128127
* @param string $description
129-
*
130128
* @return mixed
131129
*/
132130
public function updateRelease($project_id, $tag_name, $description)
@@ -186,7 +184,6 @@ public function commit($project_id, $sha)
186184
* @param int $project_id
187185
* @param $sha
188186
* @param array $parameters
189-
*
190187
* @return mixed
191188
*/
192189
public function commitRefs($project_id, $sha, array $parameters = [])
@@ -261,10 +258,9 @@ public function createCommit($project_id, array $parameters = [])
261258
}
262259

263260
/**
264-
* @param int $project_id
261+
* @param int $project_id
265262
* @param string $sha
266-
* @param array $parameters
267-
*
263+
* @param array $parameters
268264
* @return mixed
269265
*/
270266
public function commitComments($project_id, $sha, array $parameters = [])

test/Gitlab/Tests/Api/GroupsTest.php

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

297+
/**
298+
* @test
299+
*/
300+
public function shouldGetLabels()
301+
{
302+
$expectedArray = array(
303+
array('name' => 'bug', 'color' => '#000000'),
304+
array('name' => 'feature', 'color' => '#ff0000')
305+
);
306+
307+
$api = $this->getApiMock();
308+
$api->expects($this->once())
309+
->method('get')
310+
->with('groups/1/labels')
311+
->will($this->returnValue($expectedArray))
312+
;
313+
314+
$this->assertEquals($expectedArray, $api->labels(1));
315+
}
316+
317+
/**
318+
* @test
319+
*/
320+
public function shouldAddLabel()
321+
{
322+
$expectedArray = array('name' => 'bug', 'color' => '#000000');
323+
324+
$api = $this->getApiMock();
325+
$api->expects($this->once())
326+
->method('post')
327+
->with('groups/1/labels', array('name' => 'wont-fix', 'color' => '#ffffff'))
328+
->will($this->returnValue($expectedArray))
329+
;
330+
331+
$this->assertEquals($expectedArray, $api->addLabel(1, array('name' => 'wont-fix', 'color' => '#ffffff')));
332+
}
333+
334+
/**
335+
* @test
336+
*/
337+
public function shouldUpdateLabel()
338+
{
339+
$expectedArray = array('name' => 'bug', 'color' => '#00ffff');
340+
341+
$api = $this->getApiMock();
342+
$api->expects($this->once())
343+
->method('put')
344+
->with('groups/1/labels', array('name' => 'bug', 'new_name' => 'big-bug', 'color' => '#00ffff'))
345+
->will($this->returnValue($expectedArray))
346+
;
347+
348+
$this->assertEquals($expectedArray, $api->updateLabel(1, array('name' => 'bug', 'new_name' => 'big-bug', 'color' => '#00ffff')));
349+
}
350+
351+
/**
352+
* @test
353+
*/
354+
public function shouldRemoveLabel()
355+
{
356+
$expectedBool = true;
357+
358+
$api = $this->getApiMock();
359+
$api->expects($this->once())
360+
->method('delete')
361+
->with('groups/1/labels', array('name' => 'bug'))
362+
->will($this->returnValue($expectedBool))
363+
;
364+
365+
$this->assertEquals($expectedBool, $api->removeLabel(1, 'bug'));
366+
}
367+
297368
public function shouldGetVariables()
298369
{
299370
$expectedArray = array(

0 commit comments

Comments
 (0)