From 874f4f9ca80cac282ebd1d5e3cbaf82904cd0d7d Mon Sep 17 00:00:00 2001 From: "Nek (Maxime Veber)" Date: Tue, 31 Dec 2013 17:00:33 +0100 Subject: [PATCH 1/2] Fixed 39 : urls to get informations about watching --- lib/Github/Api/Repo.php | 2 +- lib/Github/Api/User.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index e0b891841f0..a1352389422 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -367,7 +367,7 @@ public function teams($username, $repository) */ public function watchers($username, $repository, $page = 1) { - return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/watchers', array( + return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/subscribers', array( 'page' => $page )); } diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 97c3be0fda4..5e70b26c9a0 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -69,7 +69,7 @@ public function followers($username) */ public function watched($username) { - return $this->get('users/'.rawurlencode($username).'/watched'); + return $this->get('users/'.rawurlencode($username).'/subscriptions'); } /** From d17d2b82643247bb21e450be66de7c4d6a0027a7 Mon Sep 17 00:00:00 2001 From: "Maxime Veber (aka Nek)" Date: Tue, 28 Jan 2014 15:41:25 +0100 Subject: [PATCH 2/2] Deprecated watch methods --- lib/Github/Api/Repo.php | 15 +++++++++++++++ lib/Github/Api/User.php | 14 +++++++++++++- test/Github/Tests/Api/RepoTest.php | 6 +++--- test/Github/Tests/Api/UserTest.php | 6 +++--- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index a1352389422..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 @@ -366,6 +367,20 @@ public function teams($username, $repository) * @return array */ public function watchers($username, $repository, $page = 1) + { + return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/watchers', array( + 'page' => $page + )); + } + + /** + * @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 diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 5e70b26c9a0..1681d8e5217 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -62,12 +62,24 @@ 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 */ 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'); } 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')); } /**