Skip to content

Commit bf8fc46

Browse files
authored
Merge pull request #245 from mykiwi-forks/feature/award_emoji
Add award emoji
2 parents 00dbf59 + 0545bca commit bf8fc46

File tree

6 files changed

+92
-0
lines changed

6 files changed

+92
-0
lines changed

lib/Gitlab/Api/Issues.php

+11
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,15 @@ public function getTimeStats($project_id, $issue_iid)
198198
{
199199
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid) .'/time_stats'));
200200
}
201+
202+
/**
203+
* @param int $project_id
204+
* @param int $issue_iid
205+
*
206+
* @return mixed
207+
*/
208+
public function awardEmoji($project_id, $issue_iid)
209+
{
210+
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/award_emoji'));
211+
}
201212
}

lib/Gitlab/Api/MergeRequests.php

+11
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,15 @@ public function unapprove($project_id, $merge_request_iid)
242242
{
243243
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/unapprove'));
244244
}
245+
246+
/**
247+
* @param int $project_id
248+
* @param int $merge_request_iid
249+
*
250+
* @return mixed
251+
*/
252+
public function awardEmoji($project_id, $merge_request_iid)
253+
{
254+
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/award_emoji'));
255+
}
245256
}

lib/Gitlab/Api/Snippets.php

+11
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,15 @@ public function remove($project_id, $snippet_id)
6767
{
6868
return $this->delete($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id)));
6969
}
70+
71+
/**
72+
* @param int $project_id
73+
* @param int $snippet_id
74+
*
75+
* @return mixed
76+
*/
77+
public function awardEmoji($project_id, $snippet_id)
78+
{
79+
return $this->get($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id).'/award_emoji'));
80+
}
7081
}

test/Gitlab/Tests/Api/IssuesTest.php

+20
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ public function shouldGetIssueTimeStats()
270270
$this->assertEquals($expectedArray, $api->getTimeStats(1, 2));
271271
}
272272

273+
/**
274+
* @test
275+
*/
276+
public function shouldGetIssueAwardEmoji()
277+
{
278+
$expectedArray = array(
279+
array('id' => 1, 'name' => 'sparkles'),
280+
array('id' => 2, 'name' => 'heart_eyes'),
281+
);
282+
283+
$api = $this->getApiMock();
284+
$api->expects($this->once())
285+
->method('get')
286+
->with('projects/1/issues/2/award_emoji')
287+
->will($this->returnValue($expectedArray))
288+
;
289+
290+
$this->assertEquals($expectedArray, $api->awardEmoji(1, 2));
291+
}
292+
273293
protected function getApiClass()
274294
{
275295
return 'Gitlab\Api\Issues';

test/Gitlab/Tests/Api/MergeRequestsTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,25 @@ public function shouldGetMergeRequestApprovals()
266266
$this->assertEquals($expectedArray, $api->all(1, ['iids' => [2]]));
267267
}
268268

269+
/**
270+
* @test
271+
*/
272+
public function shouldGetMergeRequestAwardEmoji()
273+
{
274+
$expectedArray = array(
275+
array('id' => 1, 'name' => 'sparkles'),
276+
array('id' => 2, 'name' => 'heart_eyes'),
277+
);
278+
279+
$api = $this->getApiMock();
280+
$api->expects($this->once())
281+
->method('get')
282+
->with('projects/1/merge_requests/2/award_emoji')
283+
->will($this->returnValue($expectedArray))
284+
;
285+
286+
$this->assertEquals($expectedArray, $api->awardEmoji(1, 2));
287+
}
269288

270289
protected function getMultipleMergeRequestsData()
271290
{

test/Gitlab/Tests/Api/SnippetsTest.php

+20
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@ public function shouldRemoveSnippet()
107107
$this->assertEquals($expectedBool, $api->remove(1, 3));
108108
}
109109

110+
/**
111+
* @test
112+
*/
113+
public function shouldGetSnippetAwardEmoji()
114+
{
115+
$expectedArray = array(
116+
array('id' => 1, 'name' => 'sparkles'),
117+
array('id' => 2, 'name' => 'heart_eyes'),
118+
);
119+
120+
$api = $this->getApiMock();
121+
$api->expects($this->once())
122+
->method('get')
123+
->with('projects/1/snippets/2/award_emoji')
124+
->will($this->returnValue($expectedArray))
125+
;
126+
127+
$this->assertEquals($expectedArray, $api->awardEmoji(1, 2));
128+
}
129+
110130
protected function getApiClass()
111131
{
112132
return 'Gitlab\Api\Snippets';

0 commit comments

Comments
 (0)