Skip to content

Commit 15df546

Browse files
committed
implemented BranchRestrictions::get (API 2.0)
1 parent 7ee6c65 commit 15df546

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

docs/repositories/branch-restrictions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ $restrictions->create($account_name, $repo_slug, array(
2828
));
2929
```
3030

31+
### Get a specific restriction: (API 2.0)
32+
```php
33+
$restrictions->get($account_name, $repo_slug, $restrictionID);
34+
```
35+
3136
----
3237

3338
#### Related:

lib/Bitbucket/API/Repositories/BranchRestrictions.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,20 @@ public function create($account, $repo, $params = array())
7373
array('Content-Type' => 'application/json')
7474
);
7575
}
76+
77+
/**
78+
* Get a specific restriction
79+
*
80+
* @access public
81+
* @param string $account The team or individual account owning the repository.
82+
* @param string $repo The repository identifier.
83+
* @param int $id The restriction's identifier.
84+
* @return MessageInterface
85+
*/
86+
public function get($account, $repo, $id)
87+
{
88+
return $this->getClient()->setApiVersion('2.0')->get(
89+
sprintf('repositories/%s/%s/branch-restrictions/%d', $account, $repo, $id)
90+
);
91+
}
7692
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,22 @@ public function testCreateRestrictionFromJSONShouldFailWithInvalidRestrictionKin
8888

8989
$restrictions->create('gentle', 'eof', $params);
9090
}
91+
92+
public function testGetSpecificRestriction()
93+
{
94+
$endpoint = 'repositories/gentle/eof/branch-restrictions/1';
95+
$expectedResult = $this->fakeResponse(array('dummy'));
96+
97+
$client = $this->getHttpClientMock();
98+
$client->expects($this->once())
99+
->method('get')
100+
->with($endpoint)
101+
->will($this->returnValue($expectedResult));
102+
103+
/** @var \Bitbucket\API\Repositories\BranchRestrictions $restriction */
104+
$restriction = $this->getClassMock('Bitbucket\API\Repositories\BranchRestrictions', $client);
105+
$actual = $restriction->get('gentle', 'eof', 1);
106+
107+
$this->assertEquals($expectedResult, $actual);
108+
}
91109
}

0 commit comments

Comments
 (0)