Skip to content

Commit 50f70f0

Browse files
committed
implemented PullRequests::decline (API 2.0)
1 parent 3b5ac57 commit 50f70f0

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

docs/repositories/pullrequests.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ $pull->accept($account_name, $repo_slug, 1, array(
9191
));
9292
```
9393

94+
### Decline a pull request:
95+
```php
96+
$pull->accept($account_name, $repo_slug, 1, array(
97+
'message' => 'Please update the docs to reflect new changes.'
98+
));
99+
```
100+
94101
----
95102

96103
#### Related:

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,22 @@ public function accept($account, $repo, $id, $params = array())
254254
$params
255255
);
256256
}
257+
258+
/**
259+
* Decline a pull request
260+
*
261+
* @access public
262+
* @param string $account The team or individual account owning the repository.
263+
* @param string $repo The repository identifier.
264+
* @param int $id (Optional) ID of the pull request
265+
* @param array $params Additional parameters.
266+
* @return MessageInterface
267+
*/
268+
public function decline($account, $repo, $id, $params = array())
269+
{
270+
return $this->getClient()->setApiVersion('2.0')->post(
271+
sprintf('repositories/%s/%s/pullrequests/%d/decline', $account, $repo, $id),
272+
$params
273+
);
274+
}
257275
}

test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,22 @@ public function testAcceptAndMergeAPullRequest()
273273

274274
$pull->accept('gentle', 'eof', 1, $params);
275275
}
276+
277+
public function testDeclineAPullRequest()
278+
{
279+
$endpoint = 'repositories/gentle/eof/pullrequests/1/decline';
280+
$params = array(
281+
'message' => 'Please update the test suite.',
282+
);
283+
284+
$client = $this->getHttpClientMock();
285+
$client->expects($this->once())
286+
->method('post')
287+
->with($endpoint, $params);
288+
289+
/** @var \Bitbucket\API\Repositories\PullRequests $pull */
290+
$pull = $this->getClassMock('Bitbucket\API\Repositories\PullRequests', $client);
291+
292+
$pull->decline('gentle', 'eof', 1, $params);
293+
}
276294
}

0 commit comments

Comments
 (0)