Skip to content

Commit 9dc3e9b

Browse files
committed
Merge branch 'release/0.2.1'
2 parents 7929c50 + 06d8bb4 commit 9dc3e9b

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

docs/repositories/pullrequests.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ $pull->comments()->update($account_name, $repo_slug, 41, 4, "dummy content [edit
3434
$pull->comments()->delete($account_name, $repo_slug, 41, 4);
3535
```
3636

37+
### Get all pull requests
38+
```php
39+
$pull->all($account_name, $repo_slug);
40+
```
41+
3742
----
3843

3944
#### Related:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
require_once __DIR__.'/../../vendor/autoload.php';
4+
5+
$pullRequests = new Bitbucket\API\Repositories\PullRequests;
6+
7+
// Your Bitbucket credentials
8+
$bb_user = 'username';
9+
$bb_pass = 'password';
10+
11+
/**
12+
* $accountname The team or individual account owning the repository.
13+
* repo_slub The repository identifier.
14+
*/
15+
$accountname = 'company';
16+
$repo_slug = 'sandbox';
17+
18+
// login
19+
$pullRequests->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
20+
21+
# get list of pull requests
22+
print_r($pullRequests->all($accountname, $repo_slug));

lib/Bitbucket/API/Http/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Client implements ClientInterface
3333
'api_versions' => array('1.0', '2.0'), // supported versions
3434
'format' => 'json',
3535
'formats' => array('json', 'xml'), // supported response formats
36-
'user_agent' => 'bitbucket-api-php/0.2.0 (https://bitbucket.org/gentlero/bitbucket-api)',
36+
'user_agent' => 'bitbucket-api-php/0.2.1 (https://bitbucket.org/gentlero/bitbucket-api)',
3737
'timeout' => 10,
3838
'verify_peer' => false
3939
);

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,21 @@ public function comments()
3333
{
3434
return $this->childFactory('Repositories\\PullRequests\\Comments');
3535
}
36+
37+
/**
38+
* Get a list of pull requests
39+
*
40+
* @access public
41+
* @param string $account The team or individual account owning the repository.
42+
* @param string $repo The repository identifier.
43+
* @return mixed
44+
*/
45+
public function all($account, $repo)
46+
{
47+
$this->httpClient->setApiVersion('2.0');
48+
49+
return $this->requestGet(
50+
sprintf('repositories/%s/%s/pullrequests', $account, $repo)
51+
);
52+
}
3653
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010
*/
1111
class PullRequestsTest extends Tests\TestCase
1212
{
13-
public function testDummy()
14-
{}
13+
public function testGetAllPullRequests()
14+
{
15+
$endpoint = 'repositories/gentle/eof/pullrequests';
16+
$expectedResult = json_encode('dummy');
17+
18+
$pullRequests = $this->getApiMock('Bitbucket\API\Repositories\PullRequests');
19+
$pullRequests->expects($this->once())
20+
->method('requestGet')
21+
->with($endpoint)
22+
->will( $this->returnValue($expectedResult) );
23+
24+
/** @var $pullRequests \Bitbucket\API\Repositories\PullRequests */
25+
$actual = $pullRequests->all('gentle', 'eof');
26+
27+
$this->assertEquals($expectedResult, $actual);
28+
}
1529
}

0 commit comments

Comments
 (0)