Skip to content

Commit 70aeb9f

Browse files
authored
Merge pull request #249 from violuke/closedByMergeRequests
Allow getting merge requests which would close an issue
2 parents 65ffd89 + 200c536 commit 70aeb9f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/Gitlab/Api/Issues.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,14 @@ public function awardEmoji($project_id, $issue_iid)
213213
{
214214
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/award_emoji'));
215215
}
216+
217+
/**
218+
* @param int $project_id
219+
* @param int $issue_iid
220+
* @return mixed
221+
*/
222+
public function closedByMergeRequests($project_id, $issue_iid)
223+
{
224+
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by');
225+
}
216226
}

test/Gitlab/Tests/Api/IssuesTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,26 @@ public function shouldGetIssueAwardEmoji()
290290
$this->assertEquals($expectedArray, $api->awardEmoji(1, 2));
291291
}
292292

293+
/**
294+
* @test
295+
*/
296+
public function shouldGetIssueClosedByMergeRequests()
297+
{
298+
$expectedArray = array(
299+
array('id' => 1, 'iid' => '1111', 'title' => 'Just saving the world'),
300+
array('id' => 2, 'iid' => '1112', 'title' => 'Adding new feature to get merge requests that close an issue'),
301+
);
302+
303+
$api = $this->getApiMock();
304+
$api->expects($this->once())
305+
->method('get')
306+
->with('projects/1/issues/2/closed_by')
307+
->will($this->returnValue($expectedArray))
308+
;
309+
310+
$this->assertEquals($expectedArray, $api->closedByMergeRequests(1, 2));
311+
}
312+
293313
protected function getApiClass()
294314
{
295315
return 'Gitlab\Api\Issues';

0 commit comments

Comments
 (0)