From f7b9c469da5099c9a165f103eba26c5259e37285 Mon Sep 17 00:00:00 2001 From: Luke Cousins Date: Tue, 19 Sep 2017 09:44:57 +0100 Subject: [PATCH 1/3] Allow getting merge requests which would close an issue --- lib/Gitlab/Api/Issues.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 55fcd2e85..76887bf97 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -213,4 +213,14 @@ public function awardEmoji($project_id, $issue_iid) { return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/award_emoji')); } + + /** + * @param int $project_id + * @param int $issue_iid + * @return mixed + */ + public function closedByMergeRequests($project_id, $issue_iid) + { + return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by'); + } } From 2c494f73e75d21ffb405dcbe6114f8ec839ad79a Mon Sep 17 00:00:00 2001 From: Luke Cousins Date: Tue, 19 Sep 2017 15:24:49 +0100 Subject: [PATCH 2/3] Tabs > Spaces --- lib/Gitlab/Api/Issues.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Gitlab/Api/Issues.php b/lib/Gitlab/Api/Issues.php index 76887bf97..9fa0f74da 100644 --- a/lib/Gitlab/Api/Issues.php +++ b/lib/Gitlab/Api/Issues.php @@ -214,13 +214,13 @@ public function awardEmoji($project_id, $issue_iid) return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/award_emoji')); } - /** - * @param int $project_id - * @param int $issue_iid - * @return mixed - */ - public function closedByMergeRequests($project_id, $issue_iid) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by'); - } + /** + * @param int $project_id + * @param int $issue_iid + * @return mixed + */ + public function closedByMergeRequests($project_id, $issue_iid) + { + return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by'); + } } From 200c536033e7bbfdd9d3f012b959c36defba5a53 Mon Sep 17 00:00:00 2001 From: Luke Cousins Date: Tue, 19 Sep 2017 15:33:53 +0100 Subject: [PATCH 3/3] Adding test for getting merge requests that close issue --- test/Gitlab/Tests/Api/IssuesTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/Gitlab/Tests/Api/IssuesTest.php b/test/Gitlab/Tests/Api/IssuesTest.php index 727897b37..666d84ecf 100644 --- a/test/Gitlab/Tests/Api/IssuesTest.php +++ b/test/Gitlab/Tests/Api/IssuesTest.php @@ -290,6 +290,26 @@ public function shouldGetIssueAwardEmoji() $this->assertEquals($expectedArray, $api->awardEmoji(1, 2)); } + /** + * @test + */ + public function shouldGetIssueClosedByMergeRequests() + { + $expectedArray = array( + array('id' => 1, 'iid' => '1111', 'title' => 'Just saving the world'), + array('id' => 2, 'iid' => '1112', 'title' => 'Adding new feature to get merge requests that close an issue'), + ); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/issues/2/closed_by') + ->will($this->returnValue($expectedArray)) + ; + + $this->assertEquals($expectedArray, $api->closedByMergeRequests(1, 2)); + } + protected function getApiClass() { return 'Gitlab\Api\Issues';