Skip to content

Allow unspecified event when creating review #723

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

Merged
merged 2 commits into from
Aug 4, 2018
Merged
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
6 changes: 1 addition & 5 deletions lib/Github/Api/PullRequest/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ public function comments($username, $repository, $pullRequest, $id)
*/
public function create($username, $repository, $pullRequest, array $params = [])
{
if (!isset($params['event'])) {
throw new MissingArgumentException('event');
}

if (!in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) {
if (array_key_exists('event', $params) && !in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) {
throw new InvalidArgumentException(sprintf('"event" must be one of ["APPROVE", "REQUEST_CHANGES", "COMMENT"] ("%s" given).', $params['event']));
}

Expand Down
6 changes: 3 additions & 3 deletions test/Github/Tests/Api/PullRequest/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,18 @@ public function shouldCreateReviewComment()

/**
* @test
* @expectedException \Github\Exception\MissingArgumentException
*/
public function shouldNotCreateReviewWithoutEvent()
public function shouldCreatePendingReviewWithoutEvent()
{
$data = [
'body' => 'Nice change',
];

$api = $this->getApiMock();
$api
->expects($this->never())
->expects($this->once())
->method('post')
->with('/repos/octocat/Hello-World/pulls/12/reviews')
;

$api->create('octocat', 'Hello-World', 12, $data);
Expand Down