From 6d462fe24bdd1f7289f56e43178c130d77f87006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20W=C3=B3jcik?= Date: Tue, 30 Apr 2024 20:33:45 +0200 Subject: [PATCH] add merge request remove method --- src/Api/MergeRequests.php | 16 ++++++++++++++++ tests/Api/MergeRequestsTest.php | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/Api/MergeRequests.php b/src/Api/MergeRequests.php index 2bb8584a..89b789b3 100644 --- a/src/Api/MergeRequests.php +++ b/src/Api/MergeRequests.php @@ -217,6 +217,22 @@ public function update($project_id, int $mr_iid, array $parameters) return $this->put($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid)), $parameters); } + /** + * @param int|string $project_id + * @param int $mr_iid + * + * @return mixed + */ + public function remove($project_id, int $mr_iid) + { + return $this->delete( + $this->getProjectPath( + $project_id, + 'merge_requests/'.self::encodePath($mr_iid) + ) + ); + } + /** * @param int|string $project_id * @param int $mr_iid diff --git a/tests/Api/MergeRequestsTest.php b/tests/Api/MergeRequestsTest.php index 227b89a0..78d22434 100644 --- a/tests/Api/MergeRequestsTest.php +++ b/tests/Api/MergeRequestsTest.php @@ -245,6 +245,22 @@ public function shouldUpdateMergeRequest(): void ])); } + /** + * @test + */ + public function shouldRemoveMergeRequest(): void + { + $expectedBool = true; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with('projects/1/merge_requests/2') + ->will($this->returnValue($expectedBool)); + + $this->assertEquals($expectedBool, $api->remove(1, 2)); + } + /** * @test */