Skip to content

test: refactor test suite, upgrade to PHPUnit 13 and fill coverage gaps - #41

Merged
lindyhopchris merged 3 commits into
developfrom
refactor/test-naming
Nov 14, 2026
Merged

lindyhopchris merged 3 commits into
developfrom
refactor/test-naming

Conversation

@lindyhopchris

@lindyhopchris lindyhopchris commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Summary

This brings the whole test suite in line with the unit-testing Claude skill in .claude/skills/unit-testing/SKILL.md, upgrades to PHPUnit 13, and fills the coverage gaps. All the changes are dev-only, and src/ is untouched.

Commits

  1. refactor: use it_ test names, PHPUnit attributes and tearDown in all tests
    • Renames every test method to an it_ snake_case name with a #[Test] attribute.
    • Adds a tearDown() to classes that set properties in setUp() and lacked one, and fixes the unset/parent::tearDown() order.
  2. build(deps): upgrade to PHPUnit 13 and bump dev dependencies
    • Updates phpunit.xml to the 13.4 schema and fails on PHPUnit warnings, deprecations and notices.
    • Gives every mock an expects(); where no calls are asserted, the mock becomes a stub.
    • Bumps deptrac, pint, monolog and phpstan.
  3. test: fill coverage gaps and align tests with the unit-testing skill
    • Adds tests for behaviour that had none, including Monolog ContextualProcessor/RecursiveParser, IdentifierFactory, FakeContainer, FakeLogger, the attribute autowiring on every dispatcher, queue and publisher, and the handler-container error paths.
    • Cleans up existing tests:
      • one AAA per test, with expectations at the end of arrange;
      • exact exception messages;
      • real instances and the shipped Testing fakes instead of mocks;
      • no unused mocks in setUp();
      • tests that only checked native assert() AssertionErrors are removed.

Results

Before After
Tests 466 1120
Line coverage 92.0% 99.7%

The 4 lines still uncovered can't be reached by a test: a private constructor, the function_exists guards in functions.php (they run at autoload), and the final throw in FakeUnitOfWork, which no code path reaches.

#[AllowMockObjectsWithoutExpectations] isn't used anywhere.

Related

The bugs found in src/ while writing these tests are in #40. They are not fixed here.

Test plan

  • composer all passes locally on PHP 8.5 (deptrac, phpstan level 10, pint, phpunit).
  • CI on PHP 8.4 and 8.5.

🤖 Generated with Claude Code

lindyhopchris and others added 3 commits November 14, 2026 11:35
…tests

Add a unit-testing skill and convert every test to an it_ snake_case name
with a #[Test] attribute. Unset setUp() properties in tearDown().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Migrate tests for PHPUnit 13: use stubs for test doubles without
expectations, add expects() where with() was used without one, and fix
data provider argument counts. Fail on PHPUnit warnings, deprecations and
notices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add unit tests for untested behaviour across Toolkit, Bus, Application,
Domain, Infrastructure and the Testing fakes, raising line coverage from
92% to 99.7%. The remaining uncovered lines are unreachable.

Clean up existing tests to follow the unit-testing skill: one AAA per
test, expectations at the end of arrange, exact exception messages,
real instances and shipped fakes over mocks, no unused setUp mocks, and
no tests of native assert() AssertionErrors.

Bugs found in src while writing the tests are recorded in #40.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lindyhopchris lindyhopchris self-assigned this Nov 14, 2026
@lindyhopchris
lindyhopchris merged commit 03518ba into develop Nov 14, 2026
2 checks passed
@lindyhopchris
lindyhopchris deleted the refactor/test-naming branch November 14, 2026 13:43
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.

1 participant