Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve to can specify parameters on issue comments api. #815

Merged
merged 3 commits into from Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions lib/Github/Api/Issue/Comments.php
Expand Up @@ -41,18 +41,24 @@ public function configure($bodyType = null)
*
* @link https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
*
* @param string $username
* @param string $repository
* @param int $issue
* @param int $page
* @param string $username
* @param string $repository
* @param int $issue
* @param int|array $page
t-kuni marked this conversation as resolved.
Show resolved Hide resolved
*
* @return array
*/
public function all($username, $repository, $issue, $page = 1)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/comments', [
'page' => $page,
]);
if (is_array($page)) {
$parameters = $page;
} else {
$parameters = [
t-kuni marked this conversation as resolved.
Show resolved Hide resolved
'page' => $page,
];
}

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/comments', $parameters);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions test/Github/Tests/Api/Issue/CommentsTest.php
Expand Up @@ -22,6 +22,24 @@ public function shouldGetAllIssueComments()
$this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123));
}

/**
* @test
*/
public function shouldGetAllIssueCommentsBySpecifyParameters()
{
$expectedValue = [['comment1data'], ['comment2data']];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/issues/123/comments', ['since' => '1990-08-03T00:00:00Z'])
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123, [
'since' => '1990-08-03T00:00:00Z',
]));
}

/**
* @test
*/
Expand Down