Skip to content

Commit 8a55667

Browse files
author
Kevin Howe
committed
Added the passing of GET parameters to the all method of Refs Branche and Tags
1 parent bb65b27 commit 8a55667

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

lib/Bitbucket/API/Repositories/Refs/Branches.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ class Branches extends API\Api
2424
* @access public
2525
* @param string $account The team or individual account owning the repository.
2626
* @param string $repo The repository identifier.
27+
* @param string|array $params GET parameters
2728
* @return MessageInterface
2829
*/
29-
public function all($account, $repo)
30+
public function all($account, $repo, $params = array())
3031
{
3132
return $this->getClient()->setApiVersion('2.0')->get(
32-
sprintf('repositories/%s/%s/refs/branches', $account, $repo)
33+
sprintf('repositories/%s/%s/refs/branches', $account, $repo),
34+
$params
3335
);
3436
}
3537

lib/Bitbucket/API/Repositories/Refs/Tags.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ class Tags extends API\Api
2424
* @access public
2525
* @param string $account The team or individual account owning the repository.
2626
* @param string $repo The repository identifier.
27+
* @param string|array $params GET parameters
2728
* @return MessageInterface
2829
*/
29-
public function all($account, $repo)
30+
public function all($account, $repo, $params = array())
3031
{
3132
return $this->getClient()->setApiVersion('2.0')->get(
32-
sprintf('repositories/%s/%s/refs/tags', $account, $repo)
33+
sprintf('repositories/%s/%s/refs/tags', $account, $repo),
34+
$params
3335
);
3436
}
3537

test/Bitbucket/Tests/API/Repositories/Refs/BranchesTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ public function testAll()
2525
$this->assertEquals($expectedResult, $actual);
2626
}
2727

28+
public function testAllParams()
29+
{
30+
$params = ['pagelen'=>36];
31+
$endpoint = 'repositories/gentle/eof/refs/branches';
32+
$expectedResult = json_encode('dummy');
33+
34+
$client = $this->getHttpClientMock();
35+
$client->expects($this->once())
36+
->method('get')
37+
->with($endpoint, $params)
38+
->will($this->returnValue($expectedResult));
39+
40+
$repository = $this->getClassMock('Bitbucket\API\Repositories\Refs\Branches', $client);
41+
42+
/** @var $repository \Bitbucket\API\Repositories\Refs\Branches */
43+
$actual = $repository->all('gentle', 'eof', $params);
44+
45+
$this->assertEquals($expectedResult, $actual);
46+
}
47+
2848
public function testGet()
2949
{
3050
$endpoint = 'repositories/gentle/eof/refs/branches/abranch';

test/Bitbucket/Tests/API/Repositories/Refs/TagsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ public function testAll()
2525
$this->assertEquals($expectedResult, $actual);
2626
}
2727

28+
public function testAllParams()
29+
{
30+
$params = ['pagelen'=>36];
31+
$endpoint = 'repositories/gentle/eof/refs/tags';
32+
$expectedResult = json_encode('dummy');
33+
34+
$client = $this->getHttpClientMock();
35+
$client->expects($this->once())
36+
->method('get')
37+
->with($endpoint, $params)
38+
->will($this->returnValue($expectedResult));
39+
40+
$repository = $this->getClassMock('Bitbucket\API\Repositories\Refs\Tags', $client);
41+
42+
/** @var $repository \Bitbucket\API\Repositories\Refs\Tags */
43+
$actual = $repository->all('gentle', 'eof', $params);
44+
45+
$this->assertEquals($expectedResult, $actual);
46+
}
47+
2848
public function testGet()
2949
{
3050
$endpoint = 'repositories/gentle/eof/refs/tags/atag';

0 commit comments

Comments
 (0)