Skip to content

Increase test coverage by 16.82% and fix _determineLength TypeError with neverSerializePayload#21

Merged
voku merged 4 commits intomasterfrom
copilot/increase-test-coverage-15-percent
Apr 24, 2026
Merged

Increase test coverage by 16.82% and fix _determineLength TypeError with neverSerializePayload#21
voku merged 4 commits intomasterfrom
copilot/increase-test-coverage-15-percent

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 24, 2026

Line coverage was at 72.41%. Added 191 new tests across three files, raising coverage to 89.23% (+16.82pp). In the process, tests uncovered a real TypeError bug in production code.

Bug fix: Request::_determineLength() crashes with neverSerializePayload()

When calling neverSerializePayload() on a request with a string body, the payload is stored internally as a single-element array. _serializePayload with SERIALIZE_PAYLOAD_NEVER returns it unchanged, then strlen(array) throws a TypeError.

// Before fix — throws TypeError: strlen(): Argument #1 must be of type string, array given
Request::post('https://api.example.com/', 'raw body')->neverSerializePayload()->send();

Fixed _determineLength to handle non-string payloads gracefully:

// Before
return \strlen($str);

// After
return \strlen((string) $str);  // also guards against array with early return

New test coverage

  • ExtraCoverageTest.phpRequest builder/auth/PSR-7 methods, Uri, Headers, Stream, MIME handlers (CsvMimeHandler, XmlMimeHandler), UploadedFile, exception classes
  • ExtraCoverageExtendedTest.phpCurl\Curl getters/setters/callbacks (no network), UriResolver static helpers (unparseUrl, relativize, removeDotSegments), Client *_request builders, all uncovered Response methods, Http/Mime helpers
  • ClientMultiAndPromiseTest.phpClientMulti all add_* methods (curl prep only, no HTTP), MultiCurl configuration, MultiCurlPromise then()/wait()/getState(), Request::_curlPrep() across all branching paths (auth, timeout, redirects, protocol versions, proxy, download, keep-alive, etc.)

This change is Reviewable

@voku voku marked this pull request as ready for review April 24, 2026 00:52
@voku voku merged commit 7a25e28 into master Apr 24, 2026
10 of 11 checks passed
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 24, 2026

Coverage Status

coverage: 89.228% (+16.8%) from 72.405% — copilot/increase-test-coverage-15-percent into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants