Skip to content
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