Skip to content

Commit d8203c8

Browse files
committed
implemented BranchRestrictions::delete (API 2.0)
1 parent 70cdff8 commit d8203c8

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

docs/repositories/branch-restrictions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ $restrictions->update($account_name, $repo_slug, $restrictionID, array(
4444
));
4545
```
4646

47+
### Delete a specific restriction: (API 2.0)
48+
```php
49+
$restrictions->delete($account_name, $repo_slug, $restrictionID);
50+
```
51+
4752
----
4853

4954
#### Related:

lib/Bitbucket/API/Repositories/BranchRestrictions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,22 @@ public function update($account, $repo, $id, $params = array())
119119
array('Content-Type' => 'application/json')
120120
);
121121
}
122+
123+
/**
124+
* Delete a specific branch restriction.
125+
*
126+
* @access public
127+
* @param string $account The team or individual account owning the repository.
128+
* @param string $repo The repository identifier.
129+
* @param int $id The restriction's identifier.
130+
* @return MessageInterface
131+
*
132+
* @throws \InvalidArgumentException
133+
*/
134+
public function delete($account, $repo, $id)
135+
{
136+
return $this->getClient()->setApiVersion('2.0')->delete(
137+
sprintf('repositories/%s/%s/branch-restrictions/%d', $account, $repo, $id)
138+
);
139+
}
122140
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,19 @@ public function testCreateRestrictionShouldFailIfKindIsSpecified()
162162

163163
$restrictions->update('gentle', 'eof', 1, $params);
164164
}
165+
166+
public function testDeleteRestriction()
167+
{
168+
$endpoint = 'repositories/gentle/eof/branch-restrictions/1';
169+
170+
$client = $this->getHttpClientMock();
171+
$client->expects($this->once())
172+
->method('delete')
173+
->with($endpoint);
174+
175+
/** @var \Bitbucket\API\Repositories\BranchRestrictions $restriction */
176+
$restriction = $this->getClassMock('Bitbucket\API\Repositories\BranchRestrictions', $client);
177+
178+
$restriction->delete('gentle', 'eof', 1);
179+
}
165180
}

0 commit comments

Comments
 (0)