diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index e0b891841f0..2ba40fdee67 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -359,6 +359,7 @@ public function teams($username, $repository) } /** + * @deprecated see subscribers method * @param string $username * @param string $repository * @param integer $page @@ -372,6 +373,20 @@ public function watchers($username, $repository, $page = 1) )); } + /** + * @param string $username + * @param string $repository + * @param integer $page + * + * @return array + */ + public function subscribers($username, $repository, $page = 1) + { + return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/subscribers', array( + 'page' => $page + )); + } + /** * Perform a merge * @link http://developer.github.com/v3/repos/merging/ diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 97c3be0fda4..1681d8e5217 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -62,7 +62,7 @@ public function followers($username) /** * Request the repository that a specific user is watching - * @link http://developer.github.com/v3/repos/watching/ + * @deprecated see subscriptions method * * @param string $username the username * @return array list of watched repositories @@ -72,6 +72,18 @@ public function watched($username) return $this->get('users/'.rawurlencode($username).'/watched'); } + /** + * Request the repository that a specific user is watching + * @link http://developer.github.com/v3/activity/watching/ + * + * @param string $username the username + * @return array list of watched repositories + */ + public function subscriptions($username) + { + return $this->get('users/'.rawurlencode($username).'/subscriptions'); + } + /** * Get the repositories of a user * @link http://developer.github.com/v3/repos/ diff --git a/test/Github/Tests/Api/RepoTest.php b/test/Github/Tests/Api/RepoTest.php index db125a72622..84fba69f843 100644 --- a/test/Github/Tests/Api/RepoTest.php +++ b/test/Github/Tests/Api/RepoTest.php @@ -111,17 +111,17 @@ public function shouldCreateRepositoryForOrganization() /** * @test */ - public function shouldGetRepositoryWatchers() + public function shouldGetRepositorySubscribers() { $expectedArray = array(array('id' => 1, 'username' => 'l3l0')); $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('repos/KnpLabs/php-github-api/watchers', array('page' => 2)) + ->with('repos/KnpLabs/php-github-api/subscribers', array('page' => 2)) ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->watchers('KnpLabs', 'php-github-api', 2)); + $this->assertEquals($expectedArray, $api->subscribers('KnpLabs', 'php-github-api', 2)); } /** diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index dd3811dd8fb..95dcb542e5f 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -74,17 +74,17 @@ public function shouldGetUserFollowers() /** * @test */ - public function shouldGetWatchedRepositories() + public function shouldGetSubscriptionsToRepositories() { $expectedArray = array(array('id' => 1, 'name' => 'l3l0repo')); $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('users/l3l0/watched') + ->with('users/l3l0/subscriptions') ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->watched('l3l0')); + $this->assertEquals($expectedArray, $api->subscriptions('l3l0')); } /**