Skip to content

Allow getting merge requests which would close an issue #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/Gitlab/Api/Issues.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
20 changes: 20 additions & 0 deletions test/Gitlab/Tests/Api/IssuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down