From bc07ff089242dbff39c99280a8c5bccc1aabe882 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Wed, 6 May 2026 15:31:04 +0100 Subject: [PATCH] Add merge request award emoji endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cédric MORIN <342805+Cerdic@users.noreply.github.com> Co-authored-by: Anton Komarev <1849174+antonkomarev@users.noreply.github.com> --- CHANGELOG.md | 1 + src/Api/MergeRequests.php | 30 +++++++++++ tests/Api/MergeRequestsTest.php | 92 +++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f27ec00b..1aa2d0e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add support for additional filters and ordering options in `MergeRequests::all` * Add support for project CI/CD job token scope endpoints * Add support for merge request resource label event endpoints +* Add support for merge request and merge request note award emoji endpoints * Add support for `Environments::stopStale` * Add support for `last_activity_after` and `last_activity_before` in `Groups::projects` * Fix `Projects::pipelines` date filters to include time information diff --git a/src/Api/MergeRequests.php b/src/Api/MergeRequests.php index a59d3281..850285a6 100644 --- a/src/Api/MergeRequests.php +++ b/src/Api/MergeRequests.php @@ -342,6 +342,26 @@ public function removeNote(int|string $project_id, int $mr_iid, int $note_id): m return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id))); } + public function showNoteAwardEmojis(int|string $project_id, int $mr_iid, int $note_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji')); + } + + public function showNoteAwardEmoji(int|string $project_id, int $mr_iid, int $note_id, int $award_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji/'.self::encodePath($award_id))); + } + + public function addNoteAwardEmoji(int|string $project_id, int $mr_iid, int $note_id, string $name): mixed + { + return $this->post($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji'), ['name' => $name]); + } + + public function removeNoteAwardEmoji(int|string $project_id, int $mr_iid, int $note_id, int $award_id): mixed + { + return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji/'.self::encodePath($award_id))); + } + public function showDiscussions(int|string $project_id, int $mr_iid): mixed { return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid)).'/discussions'); @@ -429,6 +449,16 @@ public function awardEmoji(int|string $project_id, int $mr_iid): mixed return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji')); } + public function showAwardEmoji(int|string $project_id, int $mr_iid, int $award_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji/'.self::encodePath($award_id))); + } + + public function addAwardEmoji(int|string $project_id, int $mr_iid, string $name): mixed + { + return $this->post($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji'), ['name' => $name]); + } + public function removeAwardEmoji(int|string $project_id, int $mr_iid, int $award_id): mixed { return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji/'.self::encodePath($award_id))); diff --git a/tests/Api/MergeRequestsTest.php b/tests/Api/MergeRequestsTest.php index 0010e650..9d7090c6 100644 --- a/tests/Api/MergeRequestsTest.php +++ b/tests/Api/MergeRequestsTest.php @@ -410,6 +410,68 @@ public function shouldRemoveNote(): void $this->assertEquals($expectedBool, $api->removeNote(1, 2, 3)); } + #[Test] + public function shouldShowMergeRequestNoteAwardEmojis(): void + { + $expectedArray = [ + ['id' => 1, 'name' => 'sparkles'], + ['id' => 2, 'name' => 'heart_eyes'], + ]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/merge_requests/2/notes/3/award_emoji') + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->showNoteAwardEmojis(1, 2, 3)); + } + + #[Test] + public function shouldShowMergeRequestNoteAwardEmoji(): void + { + $expectedArray = ['id' => 4, 'name' => 'sparkles']; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/merge_requests/2/notes/3/award_emoji/4') + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->showNoteAwardEmoji(1, 2, 3, 4)); + } + + #[Test] + public function shouldAddMergeRequestNoteAwardEmoji(): void + { + $expectedArray = ['id' => 4, 'name' => 'sparkles']; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with('projects/1/merge_requests/2/notes/3/award_emoji', ['name' => 'sparkles']) + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->addNoteAwardEmoji(1, 2, 3, 'sparkles')); + } + + #[Test] + public function shouldRemoveMergeRequestNoteAwardEmoji(): void + { + $expectedBool = true; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with('projects/1/merge_requests/2/notes/3/award_emoji/4') + ->willReturn($expectedBool); + + $this->assertEquals($expectedBool, $api->removeNoteAwardEmoji(1, 2, 3, 4)); + } + #[Test] public function shouldGetMergeRequestParticipants(): void { @@ -705,6 +767,36 @@ public function shouldIssueMergeRequestAwardEmoji(): void $this->assertEquals($expectedArray, $api->awardEmoji(1, 2)); } + #[Test] + public function shouldShowMergeRequestAwardEmoji(): void + { + $expectedArray = ['id' => 3, 'name' => 'sparkles']; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/merge_requests/2/award_emoji/3') + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->showAwardEmoji(1, 2, 3)); + } + + #[Test] + public function shouldAddMergeRequestAwardEmoji(): void + { + $expectedArray = ['id' => 3, 'name' => 'sparkles']; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with('projects/1/merge_requests/2/award_emoji', ['name' => 'sparkles']) + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->addAwardEmoji(1, 2, 'sparkles')); + } + #[Test] public function shouldRevokeMergeRequestAwardEmoji(): void {