Skip to content

Commit e86e8e1

Browse files
committed
implemented Users::following (API 2.0)
1 parent 9a03560 commit e86e8e1

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

docs/users.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ $user->get($username);
1919
$user->followers($username);
2020
```
2121

22+
### Get a list of accounts the user is following: (API 2.0)
23+
```php
24+
$user->following($username);
25+
```
2226

2327
----
2428

lib/Bitbucket/API/Users.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ public function followers($username)
4949
);
5050
}
5151

52+
/**
53+
* Get a list of accounts the user is following
54+
*
55+
* @access public
56+
* @param string $username
57+
* @return MessageInterface
58+
*/
59+
public function following($username)
60+
{
61+
return $this->getClient()->setApiVersion('2.0')->get(
62+
sprintf('users/%s/following', $username)
63+
);
64+
}
65+
5266
/**
5367
* Get account
5468
*

test/Bitbucket/Tests/API/UsersTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ public function testGetUserFollowers()
5656
$this->assertEquals($expectedResult, $actual);
5757
}
5858

59+
public function testGetUserFollowing()
60+
{
61+
$endpoint = 'users/john-doe/following';
62+
$expectedResult = $this->fakeResponse(array('dummy'));
63+
64+
$client = $this->getHttpClientMock();
65+
$client->expects($this->once())
66+
->method('get')
67+
->with($endpoint)
68+
->will($this->returnValue($expectedResult));
69+
70+
/** @var \Bitbucket\API\Users $user */
71+
$user = $this->getClassMock('Bitbucket\API\Users', $client);
72+
$actual = $user->following('john-doe');
73+
74+
$this->assertEquals($expectedResult, $actual);
75+
}
76+
5977
public function testGetAccountInstance()
6078
{
6179
$this->assertInstanceOf('\Bitbucket\API\Users\Account', $this->users->account());

0 commit comments

Comments
 (0)