Skip to content

Commit

Permalink
Merge pull request #845 from deetergp/scott_addTeamPrAbilty
Browse files Browse the repository at this point in the history
Allow create & remove to set and remove requests for teams
  • Loading branch information
acrobat committed Jan 22, 2020
2 parents ffddf1d + 0a19add commit d404193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/Github/Api/PullRequest/ReviewRequest.php
Expand Up @@ -39,12 +39,13 @@ public function all($username, $repository, $pullRequest, array $params = [])
* @param string $repository
* @param int $pullRequest
* @param array $reviewers
* @param array $teamReviewers
*
* @return string
*/
public function create($username, $repository, $pullRequest, array $reviewers)
public function create($username, $repository, $pullRequest, array $reviewers = [], array $teamReviewers = [])
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', ['reviewers' => $reviewers]);
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', ['reviewers' => $reviewers, 'team_reviewers' => $teamReviewers]);
}

/**
Expand All @@ -54,11 +55,12 @@ public function create($username, $repository, $pullRequest, array $reviewers)
* @param string $repository
* @param int $pullRequest
* @param array $reviewers
* @param array $teamReviewers
*
* @return string
*/
public function remove($username, $repository, $pullRequest, array $reviewers)
public function remove($username, $repository, $pullRequest, array $reviewers = [], array $teamReviewers = [])
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', ['reviewers' => $reviewers]);
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', ['reviewers' => $reviewers, 'team_reviewers' => $teamReviewers]);
}
}
8 changes: 4 additions & 4 deletions test/Github/Tests/Api/PullRequest/ReviewRequestTest.php
Expand Up @@ -35,10 +35,10 @@ public function shouldCreateReviewRequest()
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser']])
->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser'], 'team_reviewers' => ['testteam']])
;

$api->create('octocat', 'Hello-World', 12, ['testuser']);
$api->create('octocat', 'Hello-World', 12, ['testuser'], ['testteam']);
}

/**
Expand All @@ -49,10 +49,10 @@ public function shouldDeleteReviewRequest()
$api = $this->getApiMock();
$api->expects($this->once())
->method('delete')
->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser']])
->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser'], 'team_reviewers' => ['testteam']])
;

$api->remove('octocat', 'Hello-World', 12, ['testuser']);
$api->remove('octocat', 'Hello-World', 12, ['testuser'], ['testteam']);
}

/**
Expand Down

0 comments on commit d404193

Please sign in to comment.