From bf83136e00b92deb52fd2c3b3133523ffe03fcc1 Mon Sep 17 00:00:00 2001 From: Romain Gautier Date: Tue, 29 Aug 2017 09:59:37 +0200 Subject: [PATCH 1/2] add award_emoji API's --- lib/Gitlab/Api/Issues.php | 11 +++++++++++ lib/Gitlab/Api/MergeRequests.php | 11 +++++++++++ lib/Gitlab/Api/Snippets.php | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 9eb7e67a4..9952ccea0 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -198,4 +198,15 @@ public function getTimeStats($project_id, $issue_iid) { return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid) .'/time_stats')); } + + /** + * @param int $project_id + * @param int $issue_iid + * + * @return mixed + */ + public function awardEmoji($project_id, $issue_iid) + { + return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/award_emoji')); + } } diff --git a/lib/Gitlab/Api/MergeRequests.php b/lib/Gitlab/Api/MergeRequests.php index 691ca393e..0cdc602dd 100644 --- a/lib/Gitlab/Api/MergeRequests.php +++ b/lib/Gitlab/Api/MergeRequests.php @@ -242,4 +242,15 @@ public function unapprove($project_id, $merge_request_iid) { return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/unapprove')); } + + /** + * @param int $project_id + * @param int $merge_request_iid + * + * @return mixed + */ + public function awardEmoji($project_id, $merge_request_iid) + { + return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/award_emoji')); + } } diff --git a/lib/Gitlab/Api/Snippets.php b/lib/Gitlab/Api/Snippets.php index 00921128c..e17c0cba7 100644 --- a/lib/Gitlab/Api/Snippets.php +++ b/lib/Gitlab/Api/Snippets.php @@ -67,4 +67,15 @@ public function remove($project_id, $snippet_id) { return $this->delete($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id))); } + + /** + * @param int $project_id + * @param int $snippet_id + * + * @return mixed + */ + public function awardEmoji($project_id, $snippet_id) + { + return $this->get($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id).'/award_emoji')); + } } From 0545bcaac709b4f807e6cbdbd04b7b887f4662b9 Mon Sep 17 00:00:00 2001 From: Romain Gautier Date: Mon, 11 Sep 2017 11:43:51 +0200 Subject: [PATCH 2/2] add tests --- test/Gitlab/Tests/Api/IssuesTest.php | 20 ++++++++++++++++++++ test/Gitlab/Tests/Api/MergeRequestsTest.php | 19 +++++++++++++++++++ test/Gitlab/Tests/Api/SnippetsTest.php | 20 ++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/test/Gitlab/Tests/Api/IssuesTest.php b/test/Gitlab/Tests/Api/IssuesTest.php index 0bd9e66fa..727897b37 100644 --- a/test/Gitlab/Tests/Api/IssuesTest.php +++ b/test/Gitlab/Tests/Api/IssuesTest.php @@ -270,6 +270,26 @@ public function shouldGetIssueTimeStats() $this->assertEquals($expectedArray, $api->getTimeStats(1, 2)); } + /** + * @test + */ + public function shouldGetIssueAwardEmoji() + { + $expectedArray = array( + array('id' => 1, 'name' => 'sparkles'), + array('id' => 2, 'name' => 'heart_eyes'), + ); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/issues/2/award_emoji') + ->will($this->returnValue($expectedArray)) + ; + + $this->assertEquals($expectedArray, $api->awardEmoji(1, 2)); + } + protected function getApiClass() { return 'Gitlab\Api\Issues'; diff --git a/test/Gitlab/Tests/Api/MergeRequestsTest.php b/test/Gitlab/Tests/Api/MergeRequestsTest.php index 6605c7ea4..e13a0aebd 100644 --- a/test/Gitlab/Tests/Api/MergeRequestsTest.php +++ b/test/Gitlab/Tests/Api/MergeRequestsTest.php @@ -266,6 +266,25 @@ public function shouldGetMergeRequestApprovals() $this->assertEquals($expectedArray, $api->all(1, ['iids' => [2]])); } + /** + * @test + */ + public function shouldGetMergeRequestAwardEmoji() + { + $expectedArray = array( + array('id' => 1, 'name' => 'sparkles'), + array('id' => 2, 'name' => 'heart_eyes'), + ); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/merge_requests/2/award_emoji') + ->will($this->returnValue($expectedArray)) + ; + + $this->assertEquals($expectedArray, $api->awardEmoji(1, 2)); + } protected function getMultipleMergeRequestsData() { diff --git a/test/Gitlab/Tests/Api/SnippetsTest.php b/test/Gitlab/Tests/Api/SnippetsTest.php index 5a7c97922..f6782607f 100644 --- a/test/Gitlab/Tests/Api/SnippetsTest.php +++ b/test/Gitlab/Tests/Api/SnippetsTest.php @@ -107,6 +107,26 @@ public function shouldRemoveSnippet() $this->assertEquals($expectedBool, $api->remove(1, 3)); } + /** + * @test + */ + public function shouldGetSnippetAwardEmoji() + { + $expectedArray = array( + array('id' => 1, 'name' => 'sparkles'), + array('id' => 2, 'name' => 'heart_eyes'), + ); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/snippets/2/award_emoji') + ->will($this->returnValue($expectedArray)) + ; + + $this->assertEquals($expectedArray, $api->awardEmoji(1, 2)); + } + protected function getApiClass() { return 'Gitlab\Api\Snippets';