Repository navigation
Test the export lease, cleanup, download, and archive steps - #168
Conversation
The export pipeline had almost no tests: the unit suite covered about 20% of the plugin's lines, mostly the admin page and helpers. New tests: - LeaseTest: lease validation, the single-site and network repositories, acquisition under the lock, reclaiming expired and invalid rows, renewal, the directory update, and release. - CleanupTest: scheduling, bulk and stale cleanup, scheduled deletion, recovery of an interrupted export, deactivation, and uninstall. - DownloadTest: the download and deletion request checks, the rate limit, path and identity validation, and opening the exact file. - ArchiveTest: database compression, the manifest, tar entries, the combined ZIP, and a full build that stops at the files step. - ProcessHelperTest: the WP-CLI path checks, child environment, and log output. The doubles they use: a wpdb backed by in-memory SQLite (tests/ WpdbDouble.php), so the lease queries run unchanged; a disk-backed WP_Filesystem_Direct that reports the modes it sets, so permission checks behave on Windows as on Linux; and cron, option, site, redirect, and file-deletion stand-ins. Line coverage rises from about 20% to 63%, so the CI floor rises from 15% to 58%; the coverage job names pdo_sqlite. 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 | 211 |
| Duplication | 0 |
🟢 Coverage ∅ diff coverage · +43.25% coverage variation
Metric Results Coverage variation ✅ +43.25% coverage variation (-1.00%) Diff coverage ✅ ∅ diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (7c2ecb2) 2612 534 20.44% Head commit (b2e0f4f) 2611 (-1) 1663 (+1129) 63.69% (+43.25%) 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 (#168) 0 0 ∅ (not applicable) 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.
…inks GitHub's Ubuntu runner has a /var/www/html, the suite's ABSPATH, so the full build completes there instead of stopping at the files step. The test now checks that either outcome is clean: the staging directory is always removed, and a completed build holds the three bundle entries. Codacy's Opengrep flagged unlink() in the test doubles and fixtures; each deletes a path the test created, so each gets a nosemgrep note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
The unit suite covered about 20% of the plugin's lines, mostly the admin page and helpers. The export pipeline itself (lease, cleanup, download, archive) had almost no tests. This adds them.
LeaseTestlease.php287/299CleanupTestcleanup.php270/305DownloadTestdownload.php98/133ArchiveTestarchive.phpProcessHelperTestprocess.php(portable parts)New test doubles:
tests/WpdbDouble.php: awpdbbacked by in-memory SQLite. The plugin's lease queries run unchanged;BINARYis dropped (SQLite already compares text byte by byte), andGET_LOCK()/RELEASE_LOCK()are SQLite functions whose results a test sets. It also providesadd_option,add_network_optionand the other functions that write through it.WP_Filesystem_Direct: now implements the 14 methods the plugin uses, against the real disk. It reports back the modes it sets, so the plugin's private-permission checks behave on Windows as they do on Linux.wp_unschedule_hook,delete_option,delete_network_option,get_sites, site switching,wp_mkdir_p,wp_delete_file(_from_directory), and awp_safe_redirectthat throws, aswp_diealready does.Not covered here:
setsidand POSIX ownership checks, so Linux only.failOnSkippedwould fail a local Windows run.ABSPATHto a directory that doesn't exist.MINIMUM_LINE_COVERAGErises from 15 to 58, and the coverage job namespdo_sqlite.Testing
composer check-all,npm test(21), yamllint, actionlint and gitleaks pass.🤖 Generated with Claude Code