Skip to content

Test uninstall.php on one site and on a network - #180

Merged
PDowney merged 1 commit into
mainfrom
uninstall-coverage
Nov 26, 2026
Merged

PDowney merged 1 commit into
mainfrom
uninstall-coverage

Conversation

@PDowney

@PDowney PDowney commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

uninstall.php (186 executable lines) had no test, which left the unit suite at about 75% line coverage.

  • tests/unit/UninstallTest.php loads uninstall.php and tests each function:
    • the single-site removal, with error suppression restored;
    • the network removal, read in pages of 100, switching back and flushing the runtime cache per site;
    • every failure it reports: database object missing, unreadable or invalid site lists, the option still stored, a check that can't run, the current site changing, a site created during removal, and a failed switch to or back from a site;
    • the list of failed sites, at most the first 20;
    • the failure message, which gives the reason only for the file's own failures.
  • tests/unit/UninstallFailureTest.php runs the file in a separate process to show that a failed removal stops with wp_die() before WordPress deletes the plugin files.
  • tests/bootstrap.php gains a scriptable wpdb double, the multisite switch functions, wp_cache_supports() and wp_cache_flush_runtime(), and a callback hook on delete_option().
  • MINIMUM_LINE_COVERAGE rises from 72 to 94.

Testing

  • PHPUnit: 175 tests pass. Line coverage is 96.56% (841 of 871), up from about 75%.
  • composer check-all, yamllint, actionlint and gitleaks pass.

🤖 Generated with Claude Code

uninstall.php, about a fifth of the plugin's lines, had no test. The new
tests load it with wpdb and multisite doubles and cover the single-site
removal, the paged network removal, every failure it reports (database
unavailable, unreadable or invalid site lists, an option still stored, a
site created during removal, switching to or back from a site failing),
the at-most-20 list of failed sites, and the stop with wp_die() before
WordPress deletes the plugin files.

Line coverage of the unit suite rises from about 75% to 96.6%, so the CI
floor rises from 72% to 94%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to EngineScript Site Optimizer!

Before we review:

  • Have you tested your changes with WordPress 7.0+?
  • Are your changes compatible with PHP 8.3+?
  • Have you followed WordPress coding standards?
  • Did you update the CHANGELOG.md if needed?

Security Reminder
This plugin stores per-site settings and emits browser resource hints, so please ensure:

  • All user input is properly sanitized
  • All output is properly escaped
  • No security vulnerabilities are introduced

We'll review your PR soon.

@codacy-production

codacy-production Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 49 complexity · 0 duplication

Metric Results
Complexity 49
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · +20.96% coverage variation

Metric Results
Coverage variation ✅ +20.96% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8fba47f) 877 663 75.60%
Head commit (dc3e63b) 871 (-6) 841 (+178) 96.56% (+20.96%)

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 (#180) 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.

@PDowney
PDowney merged commit e6659e4 into main Nov 26, 2026
28 checks passed
@github-actions
github-actions Bot deleted the uninstall-coverage branch November 26, 2026 07:51
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.

1 participant