diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f438263..90b0682 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,8 +48,8 @@ jobs: with: php-version: '8.4' extensions: intl, sodium, gd, mysqli, curl, fileinfo, json, dom, simplexml, mbstring, zip, redis, memcached, apcu - coverage: pcov - ini-values: apc.enable_cli=1, mysqli.allow_local_infile=1 + coverage: xdebug + ini-values: apc.enable_cli=1, mysqli.allow_local_infile=1, xdebug.mode="develop,coverage" - name: Validate composer.json run: composer validate --no-check-publish - name: Install dependencies diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 0a62d9d..5612e72 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -420,7 +420,10 @@ public function testToStringMultipart() : void $body .= \implode("\r\n", $files[3]) . "\r\n"; $body .= $boundary . "--\r\n"; $contentLength = \strlen($body); - self::assertSame(953, $contentLength); + // The fixture is embedded twice, so derive the expected length from it + // rather than hard-coding a size that rots when the file changes. + $fileSize = \strlen((string) \file_get_contents($filepath)); + self::assertSame(931 + 2 * $fileSize, $contentLength); $message = $startLine . "\r\n" . \implode("\r\n", $headerLines) . "\r\n" . "\r\n" diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 5b9b6ed..4f96f20 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -603,16 +603,20 @@ public function testToStringWithDownloadMultipart() : void $this->response = new Response(new RequestMock()); $filename = __DIR__ . '/files/file.txt'; $boundary = \md5($filename); + // Derived from the fixture, like testToStringWithDownload above, so the + // expectation cannot drift when tests/files/file.txt changes size. + $contents = (string) \file_get_contents($filename); + $fileSize = \strlen($contents); $body = "\r\n--{$boundary}--\r\n" . "Content-Type: application/octet-stream\r\n" - . "Content-Range: bytes 0-1/11\r\n" + . "Content-Range: bytes 0-1/{$fileSize}\r\n" . "\r\n" - . 'Hi' + . \substr($contents, 0, 2) . "\r\n--{$boundary}--\r\n" . "Content-Type: application/octet-stream\r\n" - . "Content-Range: bytes 4-10/11\r\n" + . 'Content-Range: bytes 4-' . ($fileSize - 1) . "/{$fileSize}\r\n" . "\r\n" - . "Webisters!\n" + . \substr($contents, 4) . "\r\n--{$boundary}--\r\n"; $length = \strlen($body); $startLine = 'HTTP/1.1 206 Partial Content';