Skip to content

Commit a596577

Browse files
committed
implemented PullRequests::approve (API 2.0)
1 parent 1616eb6 commit a596577

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

docs/repositories/pullrequests.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ $pull->get($account_name, $repo_slug, 1);
6262
$pull->commits($account_name, $repo_slug, 1);
6363
```
6464

65+
### Approve a pull request:
66+
```php
67+
$pull->approve($account_name, $repo_slug, 1);
68+
```
69+
6570
----
6671

6772
#### Related:

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,20 @@ public function commits($account, $repo, $id)
161161
sprintf('repositories/%s/%s/pullrequests/%d/commits', $account, $repo, $id)
162162
);
163163
}
164+
165+
/**
166+
* Approve a pull request
167+
*
168+
* @access public
169+
* @param string $account The team or individual account owning the repository.
170+
* @param string $repo The repository identifier.
171+
* @param int $id ID of the pull request
172+
* @return MessageInterface
173+
*/
174+
public function approve($account, $repo, $id)
175+
{
176+
return $this->getClient()->setApiVersion('2.0')->post(
177+
sprintf('repositories/%s/%s/pullrequests/%d/approve', $account, $repo, $id)
178+
);
179+
}
164180
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,19 @@ public function testGetCommitsForSpecificPullRequest()
170170

171171
$this->assertEquals($expectedResult, $actual);
172172
}
173+
174+
public function testApproveRequest()
175+
{
176+
$endpoint = 'repositories/gentle/eof/pullrequests/1/approve';
177+
178+
$client = $this->getHttpClientMock();
179+
$client->expects($this->once())
180+
->method('post')
181+
->with($endpoint);
182+
183+
/** @var \Bitbucket\API\Repositories\PullRequests $pull */
184+
$pull = $this->getClassMock('Bitbucket\API\Repositories\PullRequests', $client);
185+
186+
$pull->approve('gentle', 'eof', 1);
187+
}
173188
}

0 commit comments

Comments
 (0)