Skip to content

Commit 96b4ff0

Browse files
mikedldacrobat
authored andcommitted
Allow unspecified event when creating review (#723)
* Allow unspecified `event` when creating review Documentation for `event` in "Create a pull request review" states that "By leaving this blank, you set the review action state to `PENDING`, which means you will need to submit the pull request review when you are ready." This means that omitting `event` is perfectly legal. * Fix review creation test case Since we now allow `event` to be missing, adjust the test case to expect POST request to be made.
1 parent a1d2faf commit 96b4ff0

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/Github/Api/PullRequest/Review.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ public function comments($username, $repository, $pullRequest, $id)
112112
*/
113113
public function create($username, $repository, $pullRequest, array $params = [])
114114
{
115-
if (!isset($params['event'])) {
116-
throw new MissingArgumentException('event');
117-
}
118-
119-
if (!in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) {
115+
if (array_key_exists('event', $params) && !in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) {
120116
throw new InvalidArgumentException(sprintf('"event" must be one of ["APPROVE", "REQUEST_CHANGES", "COMMENT"] ("%s" given).', $params['event']));
121117
}
122118

test/Github/Tests/Api/PullRequest/ReviewTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,18 @@ public function shouldCreateReviewComment()
212212

213213
/**
214214
* @test
215-
* @expectedException \Github\Exception\MissingArgumentException
216215
*/
217-
public function shouldNotCreateReviewWithoutEvent()
216+
public function shouldCreatePendingReviewWithoutEvent()
218217
{
219218
$data = [
220219
'body' => 'Nice change',
221220
];
222221

223222
$api = $this->getApiMock();
224223
$api
225-
->expects($this->never())
224+
->expects($this->once())
226225
->method('post')
226+
->with('/repos/octocat/Hello-World/pulls/12/reviews')
227227
;
228228

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

0 commit comments

Comments
 (0)