Skip to content

Commit 2e4b7c6

Browse files
committed
Revert
1 parent d526c13 commit 2e4b7c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Http/MockResponse.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class MockResponse
1212
{
1313
use CollectsHeaders,
14+
CollectsConfig,
1415
CollectsData;
1516

1617
/**
@@ -29,8 +30,9 @@ class MockResponse
2930
* @param int $status
3031
* @param array $data
3132
* @param array $headers
33+
* @param array $config
3234
*/
33-
public function __construct(mixed $data = [], int $status = 200, array $headers = [])
35+
public function __construct(mixed $data = [], int $status = 200, array $headers = [], array $config = [])
3436
{
3537
$this->status = $status;
3638

@@ -44,7 +46,7 @@ public function __construct(mixed $data = [], int $status = 200, array $headers
4446
$this->rawData = $data;
4547
}
4648

47-
$this->mergeHeaders($headers);
49+
$this->mergeHeaders($headers)->mergeConfig($config);
4850
}
4951

5052
/**
@@ -65,7 +67,7 @@ public static function fromRequest(SaloonRequest $request, int $status = 200): s
6567
? $request->defineBody()
6668
: $request->getData();
6769

68-
return new static($data, $status, $request->getHeaders());
70+
return new static($data, $status, $request->getHeaders(), $request->getConfig());
6971
}
7072

7173
/**

tests/Unit/MockResponseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
$response = MockResponse::fromRequest($request, 200);
2929

3030
expect($response->getHeaders())->toEqual(array_merge($request->getHeaders(), ['Content-Type' => 'application/json']));
31+
expect($response->getConfig())->toEqual($request->getConfig());
3132
expect($response->getStatus())->toEqual(200);
3233
});
3334

3435
test('a mock response can have raw body data', function () {
3536
$response = new MockResponse('xml', 200, ['Content-Type' => 'application/json']);
3637

3738
expect($response->getHeaders())->toEqual(['Content-Type' => 'application/json']);
39+
expect($response->getConfig())->toEqual([]);
3840
expect($response->getStatus())->toEqual(200);
3941
expect($response->getFormattedData())->toEqual('xml');
4042
});

0 commit comments

Comments
 (0)