Skip to content

Commit 1af9cde

Browse files
committed
Level 5
1 parent b52942f commit 1af9cde

14 files changed

+55
-49
lines changed

src/VCR/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Request
4040
protected $curlOptions = [];
4141

4242
/**
43-
* @param array<string,string> $headers
43+
* @param array<string,string|null> $headers
4444
*/
4545
public function __construct(string $method, ?string $url, array $headers = [])
4646
{

src/VCR/Storage/Storage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface Storage extends \Iterator
1515
/**
1616
* Stores an array of data.
1717
*
18-
* @param array<string,array<string,mixed>> $recording array to store in storage
18+
* @param array<string,string|null|array<string,mixed>> $recording array to store in storage
1919
*/
2020
public function storeRecording(array $recording): void;
2121

tests/VCR/CassetteTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function testGetName(): void
2929
public function testDontOverwriteRecord(): void
3030
{
3131
$request = new Request('GET', 'https://example.com');
32-
$response1 = new Response(200, [], 'sometest');
33-
$response2 = new Response(200, [], 'sometest');
32+
$response1 = new Response('200', [], 'sometest');
33+
$response2 = new Response('200', [], 'sometest');
3434
$this->cassette->record($request, $response1);
3535
$this->cassette->record($request, $response2);
3636

@@ -40,7 +40,7 @@ public function testDontOverwriteRecord(): void
4040
public function testPlaybackAlreadyRecordedRequest(): void
4141
{
4242
$request = new Request('GET', 'https://example.com');
43-
$response = new Response(200, [], 'sometest');
43+
$response = new Response('200', [], 'sometest');
4444
$this->cassette->record($request, $response);
4545

4646
$this->assertEquals($response->toArray(), $this->cassette->playback($request)->toArray());
@@ -56,7 +56,7 @@ public function testHasResponseNotFound(): void
5656
public function testHasResponseFound(): void
5757
{
5858
$request = new Request('GET', 'https://example.com');
59-
$response = new Response(200, [], 'sometest');
59+
$response = new Response('200', [], 'sometest');
6060
$this->cassette->record($request, $response);
6161

6262
$this->assertTrue($this->cassette->hasResponse($request), 'Expected true if request was found.');

tests/VCR/Event/AfterHttpRequestEventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AfterHttpRequestEventTest extends TestCase
1515

1616
protected function setUp(): void
1717
{
18-
$this->event = new AfterHttpRequestEvent(new Request('GET', 'http://example.com'), new Response(200));
18+
$this->event = new AfterHttpRequestEvent(new Request('GET', 'http://example.com'), new Response('200'));
1919
}
2020

2121
public function testGetRequest(): void

tests/VCR/Event/AfterPlaybackEventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function setUp(): void
2020
{
2121
$this->event = new AfterPlaybackEvent(
2222
new Request('GET', 'http://example.com'),
23-
new Response(200),
23+
new Response('200'),
2424
new Cassette('test', new Configuration(), new Storage\Blackhole())
2525
);
2626
}

tests/VCR/Event/BeforeRecordEventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function setUp(): void
2020
{
2121
$this->event = new BeforeRecordEvent(
2222
new Request('GET', 'http://example.com'),
23-
new Response(200),
23+
new Response('200'),
2424
new Cassette('test', new Configuration(), new Storage\Blackhole())
2525
);
2626
}

tests/VCR/LibraryHooks/CurlHookTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function (Request $request) use ($testClass) {
133133
'Post query string was not parsed and set correctly.'
134134
);
135135

136-
return new Response(200);
136+
return new Response('200');
137137
}
138138
);
139139

@@ -155,7 +155,7 @@ function (Request $request) use ($testClass) {
155155
'Post query string was not parsed and set correctly.'
156156
);
157157

158-
return new Response(200);
158+
return new Response('200');
159159
}
160160
);
161161

@@ -287,7 +287,7 @@ function (Request $request) use ($testClass, &$callCount) {
287287
);
288288
++$callCount;
289289

290-
return new Response(200);
290+
return new Response('200');
291291
}
292292
);
293293

@@ -299,11 +299,11 @@ function (Request $request) use ($testClass, &$callCount) {
299299
curl_multi_add_handle($curlMultiHandle, $curlHandle2);
300300

301301
$stillRunning = null;
302-
$mh = curl_multi_exec($curlMultiHandle, $stillRunning);
302+
curl_multi_exec($curlMultiHandle, $stillRunning);
303303

304-
$lastInfo = curl_multi_info_read($mh);
305-
$secondLastInfo = curl_multi_info_read($mh);
306-
$afterLastInfo = curl_multi_info_read($mh);
304+
$lastInfo = curl_multi_info_read($curlMultiHandle);
305+
$secondLastInfo = curl_multi_info_read($curlMultiHandle);
306+
$afterLastInfo = curl_multi_info_read($curlMultiHandle);
307307

308308
curl_multi_remove_handle($curlMultiHandle, $curlHandle1);
309309
curl_multi_remove_handle($curlMultiHandle, $curlHandle2);
@@ -364,7 +364,7 @@ function (Request $request) use ($testClass) {
364364
''
365365
);
366366

367-
return new Response(200);
367+
return new Response('200');
368368
}
369369
);
370370

tests/VCR/LibraryHooks/SoapHookTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function getContentCheckCallback(): Closure
100100
$testClass = $this;
101101

102102
return Closure::fromCallable(function () use ($testClass) {
103-
return new Response(200, [], $testClass->expected);
103+
return new Response('200', [], $testClass->expected);
104104
});
105105
}
106106

@@ -113,7 +113,7 @@ protected function getHeadersCheckCallback(array $expectedHeaders): Closure
113113
$test->assertEquals($expectedHeader, $request->getHeader($expectedHeaderName));
114114
}
115115

116-
return new Response(200, [], '');
116+
return new Response('200', [], '');
117117
});
118118
}
119119
}

tests/VCR/LibraryHooks/StreamWrapperHookTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testSeek(): void
3232
{
3333
$hook = new StreamWrapperHook();
3434
$hook->enable(function ($request) {
35-
return new Response(200, [], 'A Test');
35+
return new Response('200', [], 'A Test');
3636
});
3737
$hook->stream_open('http://example.com', 'r', 0, $openedPath);
3838

tests/VCR/ResponseTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testRestoreHeadersFromArray(): void
3535
'Connection' => 'close',
3636
'Date' => 'Fri, 31 Jan 2014 15:37:13 GMT',
3737
];
38-
$response = new Response(200, $headers);
38+
$response = new Response('200', $headers);
3939
$restoredResponse = Response::fromArray($response->toArray());
4040

4141
$this->assertEquals($headers, $restoredResponse->getHeaders());
@@ -59,7 +59,7 @@ public function testGetBodyNoneDefined(): void
5959
public function testRestoreBodyFromArray(): void
6060
{
6161
$body = 'this is an example body';
62-
$response = new Response(200, [], $body);
62+
$response = new Response('200', [], $body);
6363
$restoredResponse = Response::fromArray($response->toArray());
6464

6565
$this->assertEquals($body, $restoredResponse->getBody());
@@ -68,7 +68,7 @@ public function testRestoreBodyFromArray(): void
6868
public function testBase64EncodeCompressedBody(): void
6969
{
7070
$body = 'this is an example body';
71-
$response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body);
71+
$response = new Response('200', ['Content-Type' => 'application/x-gzip'], $body);
7272
$responseArray = $response->toArray();
7373

7474
$this->assertEquals(base64_encode($body), $responseArray['body']);
@@ -89,15 +89,15 @@ public function testBase64DecodeCompressedBody(): void
8989
public function testRestoreCompressedBody(): void
9090
{
9191
$body = 'this is an example body';
92-
$response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body);
92+
$response = new Response('200', ['Content-Type' => 'application/x-gzip'], $body);
9393
$restoredResponse = Response::fromArray($response->toArray());
9494

9595
$this->assertEquals($body, $restoredResponse->getBody());
9696
}
9797

9898
public function testGetStatus(): void
9999
{
100-
$expectedStatus = 200;
100+
$expectedStatus = '200';
101101

102102
$response = new Response($expectedStatus);
103103

@@ -106,7 +106,7 @@ public function testGetStatus(): void
106106

107107
public function testRestoreStatusFromArray(): void
108108
{
109-
$expectedStatus = 200;
109+
$expectedStatus = '200';
110110

111111
$response = new Response($expectedStatus);
112112
$restoredResponse = Response::fromArray($response->toArray());
@@ -117,15 +117,15 @@ public function testRestoreStatusFromArray(): void
117117
public function testGetCurlInfo(): void
118118
{
119119
$curlOptions = ['option' => 'value'];
120-
$response = new Response(200, [], null, $curlOptions);
120+
$response = new Response('200', [], null, $curlOptions);
121121

122122
$this->assertEquals($curlOptions, $response->getCurlInfo());
123123
}
124124

125125
public function testRestoreCurlInfoFromArray(): void
126126
{
127127
$expectedCurlOptions = ['option' => 'value'];
128-
$response = new Response(200, [], null, $expectedCurlOptions);
128+
$response = new Response('200', [], null, $expectedCurlOptions);
129129
$restoredResponse = Response::fromArray($response->toArray());
130130

131131
$this->assertEquals($expectedCurlOptions, $response->getCurlInfo());

0 commit comments

Comments
 (0)