Skip to content

Ignore ProtectedVisibility on ClockSensitive PHPUnit hooks#26

Merged
paulbalandan merged 1 commit into1.xfrom
claude/fix-mutation-testing-iA7c0
May 4, 2026
Merged

Ignore ProtectedVisibility on ClockSensitive PHPUnit hooks#26
paulbalandan merged 1 commit into1.xfrom
claude/fix-mutation-testing-iA7c0

Conversation

@paulbalandan
Copy link
Copy Markdown
Contributor

Summary

  • The scheduled Mutation Tests workflow has been failing every night since 2026-04-26 (runs #52 through #60). MSI was 99.56% (below the required 100%) due to two ProtectedVisibility mutants escaping in src/Nexus/Clock/Extension/ClockSensitive.phpsaveClock (line 29) and restoreClock (line 35).
  • These methods are PHPUnit #[Before] / #[After] hooks invoked via reflection, so protected vs private is invisible at the call site. PHPUnit's per-test line coverage (with either Xdebug or PCOV) does not record attribute or method-signature lines, so infection cannot link any test to those lines and reports the mutants as "Not Covered" — --with-uncovered only generates them, it does not run tests against them. (The full test suite would actually catch the mutation: changing visibility to private causes 41 errors when running phpunit --group=unit-test.)
  • Add a ProtectedVisibility entry to InfectionConfigBuilder::PER_MUTATOR_IGNORE for these two methods, then regenerate infection.json5 via bin/build-infection. This matches the existing pattern used for other false-positive mutators (AssignCoalesce, LogicalAnd, LogicalNot, ReturnRemoval, etc.). After this change, infection reports MSI 100% / Covered Code MSI 100% locally.

Test plan

  • composer test:unit — 319 tests pass
  • composer test:auto-reviewInfectionConfigTest::testInfectionJsonIsUpdated confirms infection.json5 is in sync with InfectionConfigBuilder
  • composer mutation:check — MSI 100% (450 mutants generated; 443 killed by tests, 5 caught by static analysis, 2 errors)
  • CI mutation testing job goes green on the next scheduled run

https://claude.ai/code/session_01Gdocn8KuDw4y2q4995r9Si


Generated by Claude Code

The `saveClock` and `restoreClock` methods in the `ClockSensitive` trait are
invoked by PHPUnit via `#[Before]` and `#[After]` attributes, so visibility
does not affect their invocation. PHPUnit's per-test line coverage (with
either Xdebug or PCOV) does not record attribute or method-signature lines,
so infection cannot link any test to those lines and reports the mutants as
"Not Covered" — `--with-uncovered` only generates them, it does not run
tests against them. The full test suite would actually catch the mutation
(changing visibility to `private` causes 41 errors), but infection cannot
reach those tests for these specific lines.

Add the entry to `InfectionConfigBuilder::PER_MUTATOR_IGNORE` and regenerate
`infection.json5` via `bin/build-infection`, matching the existing pattern
used for other false-positive mutators.
@paulbalandan paulbalandan force-pushed the claude/fix-mutation-testing-iA7c0 branch from f232a9b to b48f5cf Compare May 4, 2026 07:23
@paulbalandan paulbalandan merged commit ffc8652 into 1.x May 4, 2026
13 checks passed
@paulbalandan paulbalandan deleted the claude/fix-mutation-testing-iA7c0 branch May 4, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants