Skip to content

Commit f707d63

Browse files
committed
implemented Users::repositories (API 2.0)
1 parent e86e8e1 commit f707d63

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

docs/users.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ $user->followers($username);
2424
$user->following($username);
2525
```
2626

27+
### Get the list of the user's repositories: (API 2.0)
28+
```php
29+
$user->repositories($username);
30+
```
31+
2732
----
2833

2934
#### Related:

lib/Bitbucket/API/Users.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ public function following($username)
6363
);
6464
}
6565

66+
/**
67+
* Get the list of the user's repositories
68+
*
69+
* @access public
70+
* @param string $username
71+
* @return MessageInterface
72+
*/
73+
public function repositories($username)
74+
{
75+
return $this->getClient()->setApiVersion('2.0')->get(
76+
sprintf('repositories/%s', $username)
77+
);
78+
}
79+
6680
/**
6781
* Get account
6882
*

test/Bitbucket/Tests/API/UsersTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ public function testGetUserFollowing()
7474
$this->assertEquals($expectedResult, $actual);
7575
}
7676

77+
public function testGetUserRepositories()
78+
{
79+
$endpoint = 'repositories/john-doe';
80+
$expectedResult = $this->fakeResponse(array('dummy'));
81+
82+
$client = $this->getHttpClientMock();
83+
$client->expects($this->once())
84+
->method('get')
85+
->with($endpoint)
86+
->will($this->returnValue($expectedResult));
87+
88+
/** @var \Bitbucket\API\Users $user */
89+
$user = $this->getClassMock('Bitbucket\API\Users', $client);
90+
$actual = $user->repositories('john-doe');
91+
92+
$this->assertEquals($expectedResult, $actual);
93+
}
94+
7795
public function testGetAccountInstance()
7896
{
7997
$this->assertInstanceOf('\Bitbucket\API\Users\Account', $this->users->account());

0 commit comments

Comments
 (0)