Skip to content

HTTP mocking: support filename option#332

Merged
swissspidy merged 1 commit into
mainfrom
add/http-mock-filename
May 24, 2026
Merged

HTTP mocking: support filename option#332
swissspidy merged 1 commit into
mainfrom
add/http-mock-filename

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@swissspidy swissspidy added this to the 5.1.10 milestone May 24, 2026
Copilot AI review requested due to automatic review settings May 24, 2026 09:45
@swissspidy swissspidy requested a review from a team as a code owner May 24, 2026 09:45
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the HTTP request mocking helpers used in the WP-CLI test framework to support a filename option, enabling mocked responses to be written to disk (to emulate download/streaming behavior).

Changes:

  • Add support for filename in the Requests transport mock to write the mocked response body to the specified file.
  • Add support for filename in the WordPress pre_http_request mock to write the mocked body to disk.
  • Add a Behat scenario asserting that mocked requests with filename create the expected file contents.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Context/GivenStepDefinitions.php Implements filename handling in both Requests-transport and WP HTTP API mocking paths by writing the response body to disk.
features/http-mocking.feature Adds functional coverage ensuring the filename option results in a file written to the test directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +324 to 328
if ( ! empty( \$parsed_args['filename'] ) ) {
file_put_contents( \$parsed_args['filename'], \$response->body );
}

return array(
@swissspidy swissspidy merged commit 97ee70c into main May 24, 2026
84 of 87 checks passed
@swissspidy swissspidy deleted the add/http-mock-filename branch May 24, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants