Skip to content

Commit 513f508

Browse files
committed
add test for createWithConfig
1 parent c6975e5 commit 513f508

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

.github/workflows/static.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
on: [push, pull_request]
21
name: Static analysis
2+
on:
3+
push:
4+
branches:
5+
- '[0-9]+.x'
6+
- '[0-9]+.[0-9]+'
7+
- '[0-9]+.[0-9]+.x'
8+
pull_request:
39

410
jobs:
511
phpstan:

src/Promise.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ public function __construct(PromiseInterface $promise, RequestInterface $request
5353
$this->state = self::FULFILLED;
5454

5555
return $response;
56-
}, function ($reason) use ($request) {
56+
}, function ($reason) {
5757
$this->state = self::REJECTED;
5858

5959
if ($reason instanceof HttplugException) {
6060
$this->exception = $reason;
6161
} elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
62-
$this->exception = $this->handleException($reason, $request);
62+
$this->exception = $this->handleException($reason);
6363
} elseif ($reason instanceof \Throwable) {
6464
$this->exception = new HttplugException\TransferException('Invalid exception returned from Guzzle7', 0, $reason);
6565
} else {
@@ -85,7 +85,7 @@ public function wait($unwrap = true)
8585
$this->promise->wait(false);
8686

8787
if ($unwrap) {
88-
if (self::REJECTED == $this->getState()) {
88+
if (self::REJECTED === $this->getState()) {
8989
throw $this->exception;
9090
}
9191

@@ -98,7 +98,7 @@ public function wait($unwrap = true)
9898
*
9999
* @return HttplugException
100100
*/
101-
private function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request)
101+
private function handleException(GuzzleExceptions\GuzzleException $exception)
102102
{
103103
if ($exception instanceof GuzzleExceptions\ConnectException) {
104104
return new HttplugException\NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Http\Adapter\Guzzle7\Client;
6+
use Http\Client\Tests\HttpClientTest;
7+
use Psr\Http\Client\ClientInterface;
8+
9+
/**
10+
* @author David Buchmann <[email protected]>
11+
*/
12+
class DefaultHttpAdapterWithConfigTest extends HttpClientTest
13+
{
14+
protected function createHttpAdapter(): ClientInterface
15+
{
16+
$this->defaultHeaders['X-Test'] = 'configuration-value';
17+
18+
return Client::createWithConfig([
19+
'headers' => [
20+
'X-Test' => 'configuration-value',
21+
],
22+
]);
23+
}
24+
}

0 commit comments

Comments
 (0)