Skip to content

Commit 7daf5d2

Browse files
Merge branch '5.4' into 6.2
* 5.4: Avoid call on null [Notifier] Document Firebase options object in readme [ErrorHandler] Fix sending Vary header with SerializerErrorRenderer Fix intl data tests [DoctrineBridge] fix issue with missing stopwatch events [HttpClient] Fix canceling MockResponse
2 parents 66391ba + 58bb78d commit 7daf5d2

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Response/MockResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function cancel(): void
106106
}
107107

108108
$onProgress = $this->requestOptions['on_progress'] ?? static function () {};
109-
$dlSize = isset($this->headers['content-encoding']) || 'HEAD' === $this->info['http_method'] || \in_array($this->info['http_code'], [204, 304], true) ? 0 : (int) ($this->headers['content-length'][0] ?? 0);
109+
$dlSize = isset($this->headers['content-encoding']) || 'HEAD' === ($this->info['http_method'] ?? null) || \in_array($this->info['http_code'], [204, 304], true) ? 0 : (int) ($this->headers['content-length'][0] ?? 0);
110110
$onProgress($this->offset, $dlSize, $this->info);
111111
}
112112

Tests/MockHttpClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ public function testResetsRequestCount()
544544
$this->assertSame(0, $client->getRequestsCount());
545545
}
546546

547-
public function testCancellingMockResponseExecutesOnProgressWithUpdatedInfo()
547+
public function testCancelingMockResponseExecutesOnProgressWithUpdatedInfo()
548548
{
549549
$client = new MockHttpClient(new MockResponse(['foo', 'bar', 'ccc']));
550550
$canceled = false;

Tests/Response/MockResponseTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ public function testErrorIsTakenIntoAccountInInitialization()
118118
]))->getStatusCode();
119119
}
120120

121+
public function testCancelingAMockResponseNotIssuedByMockHttpClient()
122+
{
123+
$mockResponse = new MockResponse();
124+
$mockResponse->cancel();
125+
126+
$this->assertTrue($mockResponse->getInfo('canceled'));
127+
}
128+
121129
public function testMustBeIssuedByMockHttpClient()
122130
{
123131
$this->expectException(InvalidArgumentException::class);

0 commit comments

Comments
 (0)