Skip to content

Missing authenticate method in HttpClientInterface #46

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 4 commits into from
Jul 1, 2013
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
11 changes: 11 additions & 0 deletions lib/Github/HttpClient/HttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,15 @@ public function setOption($name, $value);
* @param array $headers
*/
public function setHeaders(array $headers);

/**
* Authenticate a user for all next requests
*
* @param string $tokenOrLogin GitHub private token/username/client ID
* @param null|string $password GitHub password/secret (optionally can contain $authMethod)
* @param null|string $authMethod One of the AUTH_* class constants
*
* @throws InvalidArgumentException If no authentication method was given
*/
public function authenticate($tokenOrLogin, $password, $authMethod);
}
6 changes: 3 additions & 3 deletions test/Github/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function shouldPassHttpClientInterfaceToConstructor()
*/
public function shouldAuthenticateUsingAllGivenParameters($login, $password, $method)
{
$httpClient = $this->getHttpClientMock(array('authenticate'));
$httpClient = $this->getHttpClientMock();
$httpClient->expects($this->once())
->method('authenticate')
->with($login, $password, $method);
Expand All @@ -58,7 +58,7 @@ public function getAuthenticationFullData()
*/
public function shouldAuthenticateUsingGivenParameters($token, $method)
{
$httpClient = $this->getHttpClientMock(array('authenticate'));
$httpClient = $this->getHttpClientMock();
$httpClient->expects($this->once())
->method('authenticate')
->with($token, null, $method);
Expand Down Expand Up @@ -171,7 +171,7 @@ public function getApiClassesProvider()
public function getHttpClientMock(array $methods = array())
{
$methods = array_merge(
array('get', 'post', 'patch', 'put', 'delete', 'request', 'setOption', 'setHeaders'),
array('get', 'post', 'patch', 'put', 'delete', 'request', 'setOption', 'setHeaders', 'authenticate'),
$methods
);

Expand Down
2 changes: 1 addition & 1 deletion test/Github/Tests/Mock/TestHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestHttpClient implements HttpClientInterface
public $options = array();
public $headers = array();

public function authenticate()
public function authenticate($tokenOrLogin, $password, $authMethod)
{
$this->authenticated = true;
}
Expand Down