Skip to content

Commit

Permalink
fix guzzle5 handler merge options (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Jan 24, 2018
1 parent 275a197 commit 6308640
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HttpHandler/Guzzle5HttpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private function createGuzzle5Request(RequestInterface $request, array $options)
return $this->client->createRequest(
$request->getMethod(),
$request->getUri(),
array_merge([
array_merge_recursive([
'headers' => $request->getHeaders(),
'body' => $request->getBody(),
], $options)
Expand Down
39 changes: 39 additions & 0 deletions tests/HttpHandler/Guzzle5HttpHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,43 @@ public function testPromiseHandlesException()
$promise = $handler->async($this->mockPsr7Request);
$promise->wait();
}

public function testCreateGuzzle5Request()
{
$requestHeaders = [
'header1' => 'value1',
'header2' => 'value2',
];
$this->mockPsr7Request
->expects($this->once())
->method('getHeaders')
->will($this->returnValue($requestHeaders));
$mockBody = $this->getMock('Psr\Http\Message\StreamInterface');
$this->mockPsr7Request
->expects($this->once())
->method('getBody')
->will($this->returnValue($mockBody));
$this->mockClient
->expects($this->once())
->method('createRequest')
->with(null, null, [
'headers' => $requestHeaders + ['header3' => 'value3'],
'body' => $mockBody,
])
->will($this->returnValue(
$this->getMock('GuzzleHttp\Message\RequestInterface')
));
$this->mockClient
->expects($this->once())
->method('send')
->will($this->returnValue(
$this->getMock('GuzzleHttp\Message\ResponseInterface')
));
$handler = new Guzzle5HttpHandler($this->mockClient);
$handler($this->mockPsr7Request, [
'headers' => [
'header3' => 'value3'
]
]);
}
}

0 comments on commit 6308640

Please sign in to comment.