Skip to content

Commit 4956673

Browse files
committed
update httplug to 2.0 and related package
1 parent 7e67b4c commit 4956673

File tree

9 files changed

+22
-17
lines changed

9 files changed

+22
-17
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ env:
1111
- TEST_COMMAND="vendor/bin/phpunit --verbose --coverage-text"
1212

1313
php:
14-
- 5.6
15-
- 7.0
1614
- 7.1
1715
- 7.2
1816
- 7.3

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^5.6 || ^7.0",
20+
"php": "^7.1",
2121
"psr/http-message": "^1.0",
2222
"psr/cache": "^1.0",
23-
"php-http/httplug": "^1.1",
23+
"php-http/httplug": "^2.0",
2424
"php-http/discovery": "^1.0",
2525
"php-http/client-implementation": "^1.0",
26-
"php-http/client-common": "^1.6",
26+
"php-http/client-common": "^2.0",
2727
"php-http/cache-plugin": "^1.4"
2828
},
2929
"require-dev": {
3030
"phpunit/phpunit": "^5.5 || ^6.0",
31-
"php-http/guzzle6-adapter": "^1.0",
31+
"php-http/guzzle6-adapter": "^2.0",
3232
"php-http/mock-client": "^1.0",
3333
"guzzlehttp/psr7": "^1.2",
3434
"cache/array-adapter": "^0.4"

lib/Github/HttpClient/Plugin/Authentication.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Github\Client;
66
use Github\Exception\RuntimeException;
77
use Http\Client\Common\Plugin;
8+
use Http\Promise\Promise;
89
use Psr\Http\Message\RequestInterface;
910

1011
/**
@@ -28,7 +29,7 @@ public function __construct($tokenOrLogin, $password, $method)
2829
/**
2930
* {@inheritdoc}
3031
*/
31-
public function handleRequest(RequestInterface $request, callable $next, callable $first)
32+
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
3233
{
3334
switch ($this->method) {
3435
case Client::AUTH_HTTP_PASSWORD:

lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Github\Exception\ValidationFailedException;
1010
use Github\HttpClient\Message\ResponseMediator;
1111
use Http\Client\Common\Plugin;
12+
use Http\Promise\Promise;
1213
use Psr\Http\Message\RequestInterface;
1314
use Psr\Http\Message\ResponseInterface;
1415

@@ -21,7 +22,7 @@ class GithubExceptionThrower implements Plugin
2122
/**
2223
* {@inheritdoc}
2324
*/
24-
public function handleRequest(RequestInterface $request, callable $next, callable $first)
25+
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
2526
{
2627
return $next($request)->then(function (ResponseInterface $response) use ($request) {
2728
if ($response->getStatusCode() < 400 || $response->getStatusCode() > 600) {

lib/Github/HttpClient/Plugin/History.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Github\HttpClient\Plugin;
44

55
use Http\Client\Common\Plugin\Journal;
6-
use Http\Client\Exception;
6+
use Psr\Http\Client\ClientExceptionInterface;
77
use Psr\Http\Message\RequestInterface;
88
use Psr\Http\Message\ResponseInterface;
99

@@ -32,7 +32,7 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons
3232
$this->lastResponse = $response;
3333
}
3434

35-
public function addFailure(RequestInterface $request, Exception $exception)
35+
public function addFailure(RequestInterface $request, ClientExceptionInterface $exception)
3636
{
3737
}
3838
}

lib/Github/HttpClient/Plugin/PathPrepend.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Github\HttpClient\Plugin;
44

55
use Http\Client\Common\Plugin;
6+
use Http\Promise\Promise;
67
use Psr\Http\Message\RequestInterface;
78

89
/**
@@ -25,7 +26,7 @@ public function __construct($path)
2526
/**
2627
* {@inheritdoc}
2728
*/
28-
public function handleRequest(RequestInterface $request, callable $next, callable $first)
29+
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
2930
{
3031
$currentPath = $request->getUri()->getPath();
3132
if (strpos($currentPath, $this->path) !== 0) {

test/Github/Tests/Api/AbstractApiTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Github\Api\AbstractApi;
66
use GuzzleHttp\Psr7\Response;
7+
use Http\Client\Common\HttpMethodsClientInterface;
78

89
class AbstractApiTest extends TestCase
910
{
@@ -213,9 +214,7 @@ protected function getClientMock()
213214
protected function getHttpMethodsMock(array $methods = [])
214215
{
215216
$methods = array_merge(['sendRequest'], $methods);
216-
$mock = $this->getMockBuilder(\Http\Client\Common\HttpMethodsClient::class)
217-
->disableOriginalConstructor()
218-
->setMethods($methods)
217+
$mock = $this->getMockBuilder(HttpMethodsClientInterface::class)
219218
->getMock();
220219
$mock
221220
->expects($this->any())

test/Github/Tests/HttpClient/PathPrependTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Github\HttpClient\Plugin\PathPrepend;
66
use GuzzleHttp\Psr7\Request;
7+
use GuzzleHttp\Psr7\Response;
8+
use Http\Promise\FulfilledPromise;
79
use PHPUnit\Framework\TestCase;
810

911
/**
@@ -22,6 +24,8 @@ public function testPathIsPrepended($uri, $expectedPath)
2224
$newRequest = null;
2325
$plugin->handleRequest($request, function ($request) use (&$newRequest) {
2426
$newRequest = $request;
27+
28+
return new FulfilledPromise(new Response());
2529
}, function () {
2630
throw new \RuntimeException('Did not expect plugin to call first');
2731
});

test/Github/Tests/HttpClient/Plugin/GithubExceptionThrowerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
use Github\Exception\ExceptionInterface;
66
use Github\HttpClient\Plugin\GithubExceptionThrower;
7-
use GuzzleHttp\Promise\FulfilledPromise;
87
use GuzzleHttp\Psr7\Response;
8+
use Http\Promise\FulfilledPromise;
9+
use Http\Promise\Promise;
910
use PHPUnit\Framework\TestCase;
1011
use Psr\Http\Message\RequestInterface;
1112
use Psr\Http\Message\ResponseInterface;
@@ -25,11 +26,11 @@ public function testHandleRequest(ResponseInterface $response, ExceptionInterfac
2526
/** @var RequestInterface $request */
2627
$request = $this->getMockForAbstractClass(RequestInterface::class);
2728

28-
$promise = $this->getMockBuilder(FulfilledPromise::class)->disableOriginalConstructor()->getMock();
29+
$promise = $this->getMockBuilder(Promise::class)->getMock();
2930
$promise->expects($this->once())
3031
->method('then')
3132
->willReturnCallback(function ($callback) use ($response) {
32-
return $callback($response);
33+
return new FulfilledPromise($callback($response));
3334
});
3435

3536
$plugin = new GithubExceptionThrower();

0 commit comments

Comments
 (0)