Skip to content

Commit 8bedcf3

Browse files
author
Evgeniy Guseletov
committed
Merge pull request #46 from PackageHub/master
Missing authenticate method in HttpClientInterface
2 parents 82b1a54 + f0cc9b7 commit 8bedcf3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

lib/Github/HttpClient/HttpClientInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,15 @@ public function setOption($name, $value);
9595
* @param array $headers
9696
*/
9797
public function setHeaders(array $headers);
98+
99+
/**
100+
* Authenticate a user for all next requests
101+
*
102+
* @param string $tokenOrLogin GitHub private token/username/client ID
103+
* @param null|string $password GitHub password/secret (optionally can contain $authMethod)
104+
* @param null|string $authMethod One of the AUTH_* class constants
105+
*
106+
* @throws InvalidArgumentException If no authentication method was given
107+
*/
108+
public function authenticate($tokenOrLogin, $password, $authMethod);
98109
}

test/Github/Tests/ClientTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function shouldPassHttpClientInterfaceToConstructor()
3333
*/
3434
public function shouldAuthenticateUsingAllGivenParameters($login, $password, $method)
3535
{
36-
$httpClient = $this->getHttpClientMock(array('authenticate'));
36+
$httpClient = $this->getHttpClientMock();
3737
$httpClient->expects($this->once())
3838
->method('authenticate')
3939
->with($login, $password, $method);
@@ -58,7 +58,7 @@ public function getAuthenticationFullData()
5858
*/
5959
public function shouldAuthenticateUsingGivenParameters($token, $method)
6060
{
61-
$httpClient = $this->getHttpClientMock(array('authenticate'));
61+
$httpClient = $this->getHttpClientMock();
6262
$httpClient->expects($this->once())
6363
->method('authenticate')
6464
->with($token, null, $method);
@@ -174,7 +174,7 @@ public function getApiClassesProvider()
174174
public function getHttpClientMock(array $methods = array())
175175
{
176176
$methods = array_merge(
177-
array('get', 'post', 'patch', 'put', 'delete', 'request', 'setOption', 'setHeaders'),
177+
array('get', 'post', 'patch', 'put', 'delete', 'request', 'setOption', 'setHeaders', 'authenticate'),
178178
$methods
179179
);
180180

test/Github/Tests/Mock/TestHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestHttpClient implements HttpClientInterface
1818
public $options = array();
1919
public $headers = array();
2020

21-
public function authenticate()
21+
public function authenticate($tokenOrLogin, $password, $authMethod)
2222
{
2323
$this->authenticated = true;
2424
}

0 commit comments

Comments
 (0)