Skip to content

Commit 1831db1

Browse files
authored
feature #938 Add parameters to PullRequest commits method (seanmtaylor)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- Add a `$parameters` parameter to the `PullRequest::commits()` method to allow for pagination. As per the docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#list-commits-on-a-pull-request Commits ------- 2069be2 Add parameters to PullRequest commits method 86b531f Add shouldShowCommitsFromPullRequestForPage
1 parent df653f3 commit 1831db1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/Github/Api/PullRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public function show($username, $repository, $id)
8080
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$id);
8181
}
8282

83-
public function commits($username, $repository, $id)
83+
public function commits($username, $repository, $id, array $parameters = [])
8484
{
85-
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits');
85+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits', $parameters);
8686
}
8787

8888
public function files($username, $repository, $id, array $parameters = [])

test/Github/Tests/Api/PullRequestTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ public function shouldShowCommitsFromPullRequest()
8787
$this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15'));
8888
}
8989

90+
/**
91+
* @test
92+
*/
93+
public function shouldShowCommitsFromPullRequestForPage()
94+
{
95+
$expectedArray = [['id' => 'id', 'sha' => '123123']];
96+
97+
$api = $this->getApiMock();
98+
$api->expects($this->once())
99+
->method('get')
100+
->with('/repos/ezsystems/ezpublish/pulls/15/commits', ['page' => 2, 'per_page' => 30])
101+
->willReturn($expectedArray);
102+
103+
$this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30]));
104+
}
105+
90106
/**
91107
* @test
92108
*/

0 commit comments

Comments
 (0)