Repository navigation
Test the download streaming that ends a request - #176
Conversation
esse_output_file_content() no longer ends the request: esse_serve_file_download() calls exit after it. The steps before streaming move into esse_start_file_download(). A download does the same things in the same order, and the unit suite can now run each step. New tests cover a started download (buffers cleared, rate limit started, download recorded), the streamed bytes, a stream that stops early, and a download refused before the rate limit starts. Unit coverage rises from 62.98% to 63.81%; the workflow's floor goes from 58 to 61. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for contributing to EngineScript Site Exporter! Before we review:
Security Reminder
We'll review your PR soon. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
| Duplication | 0 |
🟢 Coverage 33.33% diff coverage · +0.33% coverage variation
Metric Results Coverage variation ✅ +0.33% coverage variation (-1.00%) Diff coverage ✅ 33.33% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (fe5bf23) 2611 1663 63.69% Head commit (952d517) 2613 (+2) 1673 (+10) 64.03% (+0.33%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#176) 3 1 33.33% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
PHPUnit 13 marks a test risky when the code under test closes PHPUnit's own output buffer, which esse_serve_file_download() must do before it streams a file. The whole download now runs in a separate PHP process (tests/download-request.php): the test checks that only the file reaches the output, that no buffer is left, and, from a report written at shutdown after the exit, that the rate limit started and the download was recorded. Streaming an opened handle stays an in-process test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
esse_output_file_content()no longer callsexit;esse_serve_file_download()calls it after streaming. The steps before streaming (open and recheck the file, clear the output buffers, start the rate limit, record the download, send the headers) move into the newesse_start_file_download(). A download does the same things in the same order.tests/download-request.php), because it closes every output buffer, PHPUnit's too, and exits: only the file reaches the output, no buffer is left, and a report written at shutdown shows the rate limit started and the download was recorded. In the suite itself: streaming an opened handle sends the exact bytes and closes it; a stream that stops early is logged as an error; a file that changed is refused before the rate limit starts.MINIMUM_LINE_COVERAGEgoes from 58 to 61.No changelog entry: the plugin's behavior does not change. The
.potfile's line references are all before the changed lines.Coverage
includes/download.phpThe steps that run in the separate process (
esse_start_file_download(), buffer clearing, and theexit) are tested there but not counted as covered, because coverage is collected only in PHPUnit's process. The race checks between validation and opening stay uncovered.Checks run locally
composer test(322 tests, also three random orders, and on PHPUnit 13.4.8 as the highest-deps jobs use),composer phpcs, Codacy'sphpcs.xml,phpmd,psalm,psalm:taint,phpstan,rector,php -lon 8.4 and 8.5,yamllint,actionlint,zizmor --offline,check-jsonschema, andgitleakson the staged changes.🤖 Generated with Claude Code