Skip to content

Commit db28bea

Browse files
committed
implemented PullRequests::get (API 2.0)
1 parent c8f21e1 commit db28bea

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

docs/repositories/pullrequests.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ $pull->update('gentle', 'secret-repo', 1, array(
5252
));
5353
```
5454

55+
### Get a specific pull request:
56+
```php
57+
$pull->get($account_name, $repo_slug, 1);
58+
```
59+
5560
----
5661

5762
#### Related:

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,20 @@ public function update($account, $repo, $id, $params = array())
129129
array('Content-Type' => 'application/json')
130130
);
131131
}
132+
133+
/**
134+
* Get a specific pull request
135+
*
136+
* @access public
137+
* @param string $account The team or individual account owning the repository.
138+
* @param string $repo The repository identifier.
139+
* @param int $id ID of the pull request
140+
* @return MessageInterface
141+
*/
142+
public function get($account, $repo, $id)
143+
{
144+
return $this->getClient()->setApiVersion('2.0')->get(
145+
sprintf('repositories/%s/%s/pullrequests/%d', $account, $repo, $id)
146+
);
147+
}
132148
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,22 @@ public function testUpdatePullRequestFromArray()
134134

135135
$pull->update('gentle', 'eof', 1, $params);
136136
}
137+
138+
public function testGetSpecificPullRequest()
139+
{
140+
$endpoint = 'repositories/gentle/eof/pullrequests/1';
141+
$expectedResult = $this->fakeResponse(array('dummy'));
142+
143+
$client = $this->getHttpClientMock();
144+
$client->expects($this->once())
145+
->method('get')
146+
->with($endpoint)
147+
->will($this->returnValue($expectedResult));
148+
149+
/** @var \Bitbucket\API\Repositories\PullRequests $pull */
150+
$pull = $this->getClassMock('Bitbucket\API\Repositories\PullRequests', $client);
151+
$actual = $pull->get('gentle', 'eof', 1);
152+
153+
$this->assertEquals($expectedResult, $actual);
154+
}
137155
}

0 commit comments

Comments
 (0)