Skip to content

Commit 9a03560

Browse files
committed
implemented Users::followers (API 2.0)
1 parent dd1ba9e commit 9a03560

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

docs/users.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ Get information related to an individual or team account.
55

66
### Prepare:
77
```php
8-
$users = new Bitbucket\API\Users();
9-
$users->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
8+
$user = new Bitbucket\API\Users();
9+
$user->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
1010
```
1111

1212
### Get the public information associated with a user: (API 2.0)
1313
```php
14-
$users->get($username);
14+
$user->get($username);
1515
```
1616

17+
### Get the list of followers: (API 2.0)
18+
```php
19+
$user->followers($username);
20+
```
1721

1822

1923
----

lib/Bitbucket/API/Users.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ public function get($username)
3535
);
3636
}
3737

38+
/**
39+
* Get the list of followers.
40+
*
41+
* @access public
42+
* @param string $username
43+
* @return MessageInterface
44+
*/
45+
public function followers($username)
46+
{
47+
return $this->getClient()->setApiVersion('2.0')->get(
48+
sprintf('users/%s/followers', $username)
49+
);
50+
}
51+
3852
/**
3953
* Get account
4054
*

test/Bitbucket/Tests/API/UsersTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ public function testGetUserPublicInformation()
3838
$this->assertEquals($expectedResult, $actual);
3939
}
4040

41+
public function testGetUserFollowers()
42+
{
43+
$endpoint = 'users/john-doe/followers';
44+
$expectedResult = $this->fakeResponse(array('dummy'));
45+
46+
$client = $this->getHttpClientMock();
47+
$client->expects($this->once())
48+
->method('get')
49+
->with($endpoint)
50+
->will($this->returnValue($expectedResult));
51+
52+
/** @var \Bitbucket\API\Users $user */
53+
$user = $this->getClassMock('Bitbucket\API\Users', $client);
54+
$actual = $user->followers('john-doe');
55+
56+
$this->assertEquals($expectedResult, $actual);
57+
}
58+
4159
public function testGetAccountInstance()
4260
{
4361
$this->assertInstanceOf('\Bitbucket\API\Users\Account', $this->users->account());

0 commit comments

Comments
 (0)