Skip to content

Commit ecf6001

Browse files
Add related merge requests endpoint
Closes #507 Co-Authored-By: David Windell <[email protected]>
1 parent 7470f09 commit ecf6001

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/Gitlab/Api/Issues.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,17 @@ public function closedByMergeRequests($project_id, $issue_iid)
469469
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by');
470470
}
471471

472+
/**
473+
* @param int|string $project_id
474+
* @param int $issue_iid
475+
*
476+
* @return mixed
477+
*/
478+
public function relatedMergeRequests($project_id, $issue_iid)
479+
{
480+
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid) . '/related_merge_requests'));
481+
}
482+
472483
/**
473484
* @param int|string $project_id
474485
* @param int $issue_iid

test/Gitlab/Tests/Api/IssuesTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,26 @@ public function shouldGetIssueClosedByMergeRequests()
601601
$this->assertEquals($expectedArray, $api->closedByMergeRequests(1, 2));
602602
}
603603

604+
/**
605+
* @test
606+
*/
607+
public function shouldGetIssueRelatedMergeRequests()
608+
{
609+
$expectedArray = [
610+
['id' => 1, 'iid' => '1111', 'title' => 'Just saving the world'],
611+
['id' => 2, 'iid' => '1112', 'title' => 'Adding new feature to get merge requests that close an issue'],
612+
];
613+
614+
$api = $this->getApiMock();
615+
$api->expects($this->once())
616+
->method('get')
617+
->with('projects/1/issues/2/related_merge_requests')
618+
->will($this->returnValue($expectedArray))
619+
;
620+
621+
$this->assertEquals($expectedArray, $api->relatedMergeRequests(1, 2));
622+
}
623+
604624
/**
605625
* @test
606626
*/

0 commit comments

Comments
 (0)