Skip to content

Commit f2e1f81

Browse files
Add deployment merge request listing (#869)
Co-authored-by: Chris Mitchell <2536603+chumanfu@users.noreply.github.com>
1 parent 52427db commit f2e1f81

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* Add support for listing merge requests associated with a commit
1717
* Add support for `without_project_bots` in `Users::all`
1818
* Add support for date filters and `finished_at` ordering in `Deployments::all`
19+
* Add support for listing merge requests associated with a deployment
1920

2021

2122
## [12.0.0] - 2025-02-23

src/Api/Deployments.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ public function show(int|string $project_id, int $deployment_id): mixed
7777
{
7878
return $this->get($this->getProjectPath($project_id, 'deployments/'.$deployment_id));
7979
}
80+
81+
public function mergeRequests(int|string $project_id, int $deployment_id, array $parameters = []): mixed
82+
{
83+
return $this->get($this->getProjectPath($project_id, 'deployments/'.$deployment_id.'/merge_requests'), $parameters);
84+
}
8085
}

tests/Api/DeploymentsTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,47 @@ public function shouldShowDeployment(): void
108108
$this->assertEquals($expectedArray, $api->show(1, 42));
109109
}
110110

111+
#[Test]
112+
public function shouldGetDeploymentMergeRequests(): void
113+
{
114+
$expectedArray = [
115+
['id' => 1, 'title' => 'A merge request'],
116+
['id' => 2, 'title' => 'Another merge request'],
117+
];
118+
119+
$api = $this->getApiMock();
120+
$api->expects($this->once())
121+
->method('get')
122+
->with('projects/1/deployments/42/merge_requests', [])
123+
->willReturn($expectedArray)
124+
;
125+
126+
$this->assertEquals($expectedArray, $api->mergeRequests(1, 42));
127+
}
128+
129+
#[Test]
130+
public function shouldGetDeploymentMergeRequestsWithParameters(): void
131+
{
132+
$expectedArray = [
133+
['id' => 1, 'title' => 'A merge request'],
134+
];
135+
$parameters = [
136+
'state' => 'merged',
137+
'labels' => 'release,backend',
138+
'page' => 2,
139+
'per_page' => 25,
140+
];
141+
142+
$api = $this->getApiMock();
143+
$api->expects($this->once())
144+
->method('get')
145+
->with('projects/1/deployments/42/merge_requests', $parameters)
146+
->willReturn($expectedArray)
147+
;
148+
149+
$this->assertEquals($expectedArray, $api->mergeRequests(1, 42, $parameters));
150+
}
151+
111152
private function getMultipleDeploymentsData(): array
112153
{
113154
return [

0 commit comments

Comments
 (0)