Skip to content

Commit 9762844

Browse files
committed
implemented Repository::watchers (API 2.0)
1 parent b3dbcba commit 9762844

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

docs/repositories/repository.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ $repo->update($account_name, $repo_slug, array(
5050
$repo->delete($account_name, $repo_slug);
5151
```
5252

53+
### Gets the list of accounts watching a repository: (API 2.0)
54+
```php
55+
$repo->watchers($account_name, $repo_slug);
56+
```
57+
5358
### Fork a repository:
5459
```php
5560
$repo->fork($account_name, $repo_slug, $fork_slug, array(

lib/Bitbucket/API/Repositories/Repository.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public function update($account, $repo, array $params = array())
132132
* Delete a repository
133133
*
134134
* @access public
135-
* @param string $account The team or individual account owning the repository.
136-
* @param string $repo The repository identifier.
137-
* @return mixed
135+
* @param string $account The team or individual account owning the repository.
136+
* @param string $repo The repository identifier.
137+
* @return MessageInterface
138138
*/
139139
public function delete($account, $repo)
140140
{
@@ -143,6 +143,21 @@ public function delete($account, $repo)
143143
);
144144
}
145145

146+
/**
147+
* Gets the list of accounts watching a repository.
148+
*
149+
* @access public
150+
* @param string $account The team or individual account owning the repository.
151+
* @param string $repo The repository identifier.
152+
* @return MessageInterface
153+
*/
154+
public function watchers($account, $repo)
155+
{
156+
return $this->getClient()->setApiVersion('2.0')->get(
157+
sprintf('repositories/%s/%s/watchers', $account, $repo)
158+
);
159+
}
160+
146161
/**
147162
* Fork a repository
148163
*

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@ public function testDeleteRepository()
122122
$repo->delete('gentle', 'eof');
123123
}
124124

125+
public function testGetRepositoryWatchers()
126+
{
127+
$endpoint = 'repositories/gentle/eof/watchers';
128+
$expectedResult = $this->fakeResponse(array('dummy'));
129+
130+
$client = $this->getHttpClientMock();
131+
$client->expects($this->once())
132+
->method('get')
133+
->with($endpoint)
134+
->will($this->returnValue($expectedResult));
135+
136+
/** @var \Bitbucket\API\Repositories\Repository $repo */
137+
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
138+
$actual = $repo->watchers('gentle', 'eof');
139+
140+
$this->assertEquals($expectedResult, $actual);
141+
}
142+
125143
public function testForkRepositorySuccess()
126144
{
127145
$endpoint = 'repositories/gentle/eof/fork';

0 commit comments

Comments
 (0)