Skip to content

Commit a65a606

Browse files
committed
Fix unit test
1 parent 6d0af62 commit a65a606

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"require-dev": {
3838
"phpspec/phpspec": "^5.0 || ^6.0",
3939
"phpspec/prophecy": "^1.6.2",
40-
"laminas/laminas-diactoros": "^1.6 || ^2.0"
40+
"guzzlehttp/psr7": "^1.6",
41+
"http-interop/http-factory-guzzle": "^1.0"
4142
},
4243
"suggest": {
4344
"ext-openssl": "Allow to sign requests using RSA signature of the HTTP body."

spec/Api/AbstractSpec.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
namespace spec\Clearhaus\Api;
44

55
use Clearhaus\Client;
6+
use GuzzleHttp\Psr7;
7+
use GuzzleHttp\Psr7\Response;
68
use PhpSpec\ObjectBehavior;
7-
use Laminas\Diactoros\Response;
8-
use Laminas\Diactoros\Stream;
99

1010
abstract class AbstractSpec extends ObjectBehavior
1111
{
1212
protected function createHttpResponse(array $body) : Response
1313
{
14-
$stream = new Stream('php://memory', 'rw');
15-
$stream->write(json_encode($body, JSON_FORCE_OBJECT));
14+
$stream = Psr7\stream_for(\json_encode($body, JSON_FORCE_OBJECT));
1615
$stream->rewind();
1716

1817
$httpResponse = (new Response())

spec/ClientSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function it_is_initializable()
2626

2727
function it_should_enable_signature(Builder $builder)
2828
{
29-
$builder->addPlugin(Argument::type(Plugin::class));
29+
$builder->addPlugin(Argument::type(Plugin::class))->shouldBeCalled();
3030

3131
$builder->addPlugin(Argument::type(SignaturePlugin::class))->shouldBeCalled();
3232

@@ -35,7 +35,7 @@ function it_should_enable_signature(Builder $builder)
3535

3636
function it_should_return_http_client(Builder $builder, HttpMethodsClient $httpMethodsClient)
3737
{
38-
$builder->addPlugin(Argument::type(Plugin::class));
38+
$builder->addPlugin(Argument::type(Plugin::class))->shouldBeCalled();
3939

4040
$builder->build()->willReturn($httpMethodsClient);
4141

spec/HttpClient/Plugin/ErrorPluginSpec.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
use Clearhaus\Exception\ValidationFailedException;
1010
use Clearhaus\HttpClient\Plugin\ErrorPlugin;
1111
use Exception;
12+
use GuzzleHttp\Psr7;
13+
use GuzzleHttp\Psr7\Response;
1214
use Http\Promise\FulfilledPromise;
1315
use Http\Promise\Promise;
1416
use Http\Promise\RejectedPromise;
1517
use PhpSpec\ObjectBehavior;
1618
use Psr\Http\Message\RequestInterface;
17-
use Laminas\Diactoros\Response;
18-
use Laminas\Diactoros\Stream;
1919

2020
class ErrorPluginSpec extends ObjectBehavior
2121
{
@@ -120,8 +120,7 @@ private function createFailedHttpResponse(int $statusCode,int $errorCode, strin
120120

121121
private function createHttpResponse(array $body, int $statusCode = 200) : Response
122122
{
123-
$stream = new Stream('php://memory', 'rw');
124-
$stream->write(json_encode($body, JSON_FORCE_OBJECT));
123+
$stream = Psr7\stream_for(\json_encode($body, JSON_FORCE_OBJECT));
125124
$stream->rewind();
126125

127126
$httpResponse = (new Response())

0 commit comments

Comments
 (0)