Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/Api/Repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ public function commitRefs(int|string $project_id, string $sha, array $parameter
);
}

public function commitMergeRequests(int|string $project_id, string $sha): mixed
{
return $this->get(
$this->getProjectPath($project_id, 'repository/commits/'.self::encodePath($sha).'/merge_requests'),
);
}

/**
* @param array $parameters {
*
Expand Down
18 changes: 18 additions & 0 deletions tests/Api/RepositoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,24 @@ public function shouldGetCommitRefs(): void
$this->assertEquals($expectedArray, $api->commitRefs(1, 'abcd1234'));
}

#[Test]
public function shouldGetCommitMergeRequests(): void
{
$expectedArray = [
['id' => 1, 'title' => 'A merge request'],
['id' => 2, 'title' => 'Another merge request'],
];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('projects/1/repository/commits/abcd1234/merge_requests')
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->commitMergeRequests(1, 'abcd1234'));
}

#[Test]
#[DataProvider('dataGetCommitRefsWithParams')]
public function shouldGetCommitRefsWithParams(string $type, array $expectedArray): void
Expand Down