diff --git a/src/Api/Deployments.php b/src/Api/Deployments.php index 3770bf9d..5512e154 100644 --- a/src/Api/Deployments.php +++ b/src/Api/Deployments.php @@ -50,4 +50,9 @@ public function show(int|string $project_id, int $deployment_id): mixed { return $this->get($this->getProjectPath($project_id, 'deployments/'.$deployment_id)); } + + public function showMergeRequests(int|string $project_id, int $deployment_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'deployments/'.self::encodePath($deployment_id).'/merge_requests')); + } } diff --git a/tests/Api/DeploymentsTest.php b/tests/Api/DeploymentsTest.php index d6859206..d1f687fd 100644 --- a/tests/Api/DeploymentsTest.php +++ b/tests/Api/DeploymentsTest.php @@ -323,4 +323,25 @@ public function shouldAllowEmptyArrayIfAllExcludedByFilter(): void $this->assertEquals([], $api->all(1, ['environment' => 'test']) ); } + + #[Test] + public function shouldShowDeploymentMergeRequests(): void + { + $expectedArray = $this->getMultipleMergeRequestsData(); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/deployments/42/merge_requests') + ->willReturn($expectedArray); + $this->assertEquals($expectedArray, $api->showMergeRequests(1, 42)); + } + + protected function getMultipleMergeRequestsData(): array + { + return [ + ['id' => 1, 'title' => 'A merge request'], + ['id' => 2, 'title' => 'Another merge request'], + ]; + } }