Skip to content

Measure coverage of the main plugin file's top-level code - #160

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

PDowney merged 1 commit into
mainfrom
main-file-coverage

Conversation

@PDowney

@PDowney PDowney commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

The test bootstrap loads optimizations-ace-mc.php before PHPUnit starts recording coverage. Its constants, require_once lines and hook registrations therefore counted as missed: 13 of the file's 15 lines.

  • tests/unit/PluginFileLoadTest.php loads the plugin file in separate processes. The bootstrap skips loading the plugin there: the test's class setup sets OAM_TEST_DEFER_PLUGIN_LOAD, and the child process inherits it.
    • One test checks the constants, the plugins_loaded hook, the uninstall hook and the coordinator instance.
    • The other checks that a load while WordPress uninstalls the plugin doesn't register the uninstall hook again.
  • MINIMUM_LINE_COVERAGE rises from 85 to 94.

The remaining missed lines are the "stop when loaded directly" guards, one per file, which no test can run without ending the process.

Testing

  • PHPUnit: 154 tests pass. Line coverage is 96.97% (256 of 264), up from about 90%.
  • composer check-all, yamllint, actionlint and gitleaks pass.

🤖 Generated with Claude Code

The test bootstrap loads the main plugin file before coverage starts, so
its constants, class loading, and hook registrations counted as missed.
New tests load the file in a separate process, where the bootstrap skips
it (OAM_TEST_DEFER_PLUGIN_LOAD, set by the test's class setup): one
checks the constants and hooks, one that a load during uninstall does not
register the uninstall hook again.

Line coverage rises from about 90% to 97%, so the CI floor rises from 85%
to 94%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · +6.84% coverage variation

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

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (818389c) 263 238 90.49%
Head commit (cb0eced) 263 (+0) 256 (+18) 97.34% (+6.84%)

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

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Optimizations ACE MC!

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 changes WooCommerce, WP Store Locator, and WordPress admin screens, 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.

@PDowney
PDowney merged commit 6e078c5 into main Nov 26, 2026
31 checks passed
@github-actions
github-actions Bot deleted the main-file-coverage branch November 26, 2026 07:52
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