Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/Api/MergeRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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)));
Expand Down
92 changes: 92 additions & 0 deletions tests/Api/MergeRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down