Skip to content

Commit d51c9fe

Browse files
committed
Merge pull request #102 from Nek-/follow-github-watch-api
Fixed 39 : urls to get informations about watching
2 parents f0effe2 + d17d2b8 commit d51c9fe

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

lib/Github/Api/Repo.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ public function teams($username, $repository)
373373
}
374374

375375
/**
376+
* @deprecated see subscribers method
376377
* @param string $username
377378
* @param string $repository
378379
* @param integer $page
@@ -386,6 +387,20 @@ public function watchers($username, $repository, $page = 1)
386387
));
387388
}
388389

390+
/**
391+
* @param string $username
392+
* @param string $repository
393+
* @param integer $page
394+
*
395+
* @return array
396+
*/
397+
public function subscribers($username, $repository, $page = 1)
398+
{
399+
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/subscribers', array(
400+
'page' => $page
401+
));
402+
}
403+
389404
/**
390405
* Perform a merge
391406
* @link http://developer.github.com/v3/repos/merging/

lib/Github/Api/User.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function followers($username)
6262

6363
/**
6464
* Request the repository that a specific user is watching
65-
* @link http://developer.github.com/v3/repos/watching/
65+
* @deprecated see subscriptions method
6666
*
6767
* @param string $username the username
6868
* @return array list of watched repositories
@@ -72,6 +72,18 @@ public function watched($username)
7272
return $this->get('users/'.rawurlencode($username).'/watched');
7373
}
7474

75+
/**
76+
* Request the repository that a specific user is watching
77+
* @link http://developer.github.com/v3/activity/watching/
78+
*
79+
* @param string $username the username
80+
* @return array list of watched repositories
81+
*/
82+
public function subscriptions($username)
83+
{
84+
return $this->get('users/'.rawurlencode($username).'/subscriptions');
85+
}
86+
7587
/**
7688
* Get the repositories of a user
7789
* @link http://developer.github.com/v3/repos/

test/Github/Tests/Api/RepoTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ public function shouldCreateRepositoryForOrganization()
111111
/**
112112
* @test
113113
*/
114-
public function shouldGetRepositoryWatchers()
114+
public function shouldGetRepositorySubscribers()
115115
{
116116
$expectedArray = array(array('id' => 1, 'username' => 'l3l0'));
117117

118118
$api = $this->getApiMock();
119119
$api->expects($this->once())
120120
->method('get')
121-
->with('repos/KnpLabs/php-github-api/watchers', array('page' => 2))
121+
->with('repos/KnpLabs/php-github-api/subscribers', array('page' => 2))
122122
->will($this->returnValue($expectedArray));
123123

124-
$this->assertEquals($expectedArray, $api->watchers('KnpLabs', 'php-github-api', 2));
124+
$this->assertEquals($expectedArray, $api->subscribers('KnpLabs', 'php-github-api', 2));
125125
}
126126

127127
/**

test/Github/Tests/Api/UserTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ public function shouldGetUserFollowers()
7474
/**
7575
* @test
7676
*/
77-
public function shouldGetWatchedRepositories()
77+
public function shouldGetSubscriptionsToRepositories()
7878
{
7979
$expectedArray = array(array('id' => 1, 'name' => 'l3l0repo'));
8080

8181
$api = $this->getApiMock();
8282
$api->expects($this->once())
8383
->method('get')
84-
->with('users/l3l0/watched')
84+
->with('users/l3l0/subscriptions')
8585
->will($this->returnValue($expectedArray));
8686

87-
$this->assertEquals($expectedArray, $api->watched('l3l0'));
87+
$this->assertEquals($expectedArray, $api->subscriptions('l3l0'));
8888
}
8989

9090
/**

0 commit comments

Comments
 (0)