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

Allow create & remove to set and remove requests for teams #845

Merged
merged 2 commits into from Jan 22, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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