Skip to content

Fixed 39 : urls to get informations about watching #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/Github/Api/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ public function teams($username, $repository)
}

/**
* @deprecated see subscribers method
* @param string $username
* @param string $repository
* @param integer $page
Expand All @@ -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/
Expand Down
14 changes: 13 additions & 1 deletion lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/
Expand Down
6 changes: 3 additions & 3 deletions test/Github/Tests/Api/RepoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/Github/Tests/Api/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

/**
Expand Down