Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions lib/Github/Api/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,14 @@ public function commits($username, $repository, $id)
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits');
}

public function files($username, $repository, $id)
public function files($username, $repository, $id, array $params = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/files');
$parameters = array_merge([
'page' => 1,
'per_page' => 30,
], $params);

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/files', $parameters);
}

/**
Expand Down
40 changes: 28 additions & 12 deletions test/Github/Tests/Api/PullRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,28 @@ public function shouldShowFilesFromPullRequest()
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/ezsystems/ezpublish/pulls/15/files')
->with('/repos/ezsystems/ezpublish/pulls/15/files', ['page' => 1, 'per_page' => 30])
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->files('ezsystems', 'ezpublish', '15'));
}

/**
* @test
*/
public function shouldShowFilesFromPullRequestForPage()
{
$expectedArray = [['id' => 'id', 'sha' => '123123']];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/ezsystems/ezpublish/pulls/15/files', ['page' => 2, 'per_page' => 30])
->willReturn($expectedArray);

$this->assertSame($expectedArray, $api->files('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30]));
}

/**
* @test
*/
Expand Down Expand Up @@ -211,10 +227,10 @@ public function shouldMergePullRequestWithMergeMethod()
public function shouldCreatePullRequestUsingTitle()
{
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
];

$api = $this->getApiMock();
Expand All @@ -231,8 +247,8 @@ public function shouldCreatePullRequestUsingTitle()
public function shouldCreatePullRequestUsingIssueId()
{
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'issue' => 25,
];

Expand All @@ -251,9 +267,9 @@ public function shouldNotCreatePullRequestWithoutBase()
{
$this->expectException(MissingArgumentException::class);
$data = [
'head' => 'virtualtestbranch',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
];

$api = $this->getApiMock();
Expand All @@ -270,9 +286,9 @@ public function shouldNotCreatePullRequestWithoutHead()
{
$this->expectException(MissingArgumentException::class);
$data = [
'base' => 'master',
'base' => 'master',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
'body' => 'BODY: Testing pull-request creation from PHP Github API',
];

$api = $this->getApiMock();
Expand All @@ -289,8 +305,8 @@ public function shouldNotCreatePullRequestUsingTitleButWithoutBody()
{
$this->expectException(MissingArgumentException::class);
$data = [
'base' => 'master',
'head' => 'virtualtestbranch',
'base' => 'master',
'head' => 'virtualtestbranch',
'title' => 'TITLE: Testing pull-request creation from PHP Github API',
];

Expand Down