From 2069be213d3fc1b102a4559482a63c6260b7d550 Mon Sep 17 00:00:00 2001 From: Sean Taylor Date: Thu, 19 Nov 2020 21:48:27 +0000 Subject: [PATCH 1/2] Add parameters to PullRequest commits method --- lib/Github/Api/PullRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/PullRequest.php b/lib/Github/Api/PullRequest.php index ffc713ba4a3..fcc46c84104 100644 --- a/lib/Github/Api/PullRequest.php +++ b/lib/Github/Api/PullRequest.php @@ -80,9 +80,9 @@ public function show($username, $repository, $id) return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$id); } - public function commits($username, $repository, $id) + public function commits($username, $repository, $id, array $parameters = []) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits'); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits', $parameters); } public function files($username, $repository, $id, array $parameters = []) From 86b531f3f2e4237afeb401fc8abb8028e141f809 Mon Sep 17 00:00:00 2001 From: Sean Taylor Date: Thu, 19 Nov 2020 21:58:46 +0000 Subject: [PATCH 2/2] Add shouldShowCommitsFromPullRequestForPage --- test/Github/Tests/Api/PullRequestTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/Github/Tests/Api/PullRequestTest.php b/test/Github/Tests/Api/PullRequestTest.php index 660368fd4f5..90505535ff9 100644 --- a/test/Github/Tests/Api/PullRequestTest.php +++ b/test/Github/Tests/Api/PullRequestTest.php @@ -87,6 +87,22 @@ public function shouldShowCommitsFromPullRequest() $this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15')); } + /** + * @test + */ + public function shouldShowCommitsFromPullRequestForPage() + { + $expectedArray = [['id' => 'id', 'sha' => '123123']]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('/repos/ezsystems/ezpublish/pulls/15/commits', ['page' => 2, 'per_page' => 30]) + ->willReturn($expectedArray); + + $this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30])); + } + /** * @test */