Skip to content

feat(bridge-rector)!: split mock conversions into PHPUnit→Double, PHPUnit→Mockery and Mockery→Double sets - #351

Merged
roxblnfk merged 1 commit into
1.xfrom
feat/rector-mock-sets
Sep 24, 2026
Merged

roxblnfk merged 1 commit into
1.xfrom
feat/rector-mock-sets

Conversation

@roxblnfk

Copy link
Copy Markdown
Member

🔍 What was changed

  • Mock conversions moved out of phpunit-to-testo into three sets, each with its own folder, config and TestoRectorSetList constant: PHPUNIT_TO_DOUBLE, PHPUNIT_TO_MOCKERY, MOCKERY_TO_DOUBLE.
  • New CreateMockToMockeryRector (PHPUnit to Mockery), MockeryToDoubleRector (Mockery to Double, following Double's migration table) and MockeryIntegrationToDoubleRector (MockeryPHPUnitIntegration/MockeryTestCase to VerifiesDoubles).
  • Both PHPUnit rules now cover configured and partial mocks, willReturnMap, and every constraint without a dedicated matcher, as a predicate that reproduces PHPUnit's own evaluate().
  • Fixed: isType('integer'), Mockery::type('integer') and similar produced a Double matcher that never matched, because Double's Argument::type() reads any name outside its builtin list as a class.
  • The skill's Rector scaffolder takes several --set values, and precheck.php finds the sets in the flattened config/.

Breaking changes

  • phpunit-to-testo no longer converts mocks. Add PHPUNIT_TO_DOUBLE or PHPUNIT_TO_MOCKERY next to it.
  • CreateMockToDoubleRector moved to Testo\Bridge\Rector\PhpunitToDouble.

Review notes

  • Two deliberate departures from Double's migration table: Mockery::mock(X) becomes Double::for(X)->strict(), since a plain Mockery mock throws on unconfigured calls, and shouldNotHaveBeenCalled() becomes received('__invoke')->never(), since Mockery's version only concerns __invoke, not unused().
  • Mockery compares plain values with ==, Double with === for scalars. Tests relying on coercion fail after conversion by design.

Checklist

  • How was this tested:
    • Unit tests added
    • Constraint predicates diffed against real PHPUnit evaluate() over 56 constraints x 39 values
    • Generated code run against real Double and Mockery
    • composer test:ci -- --type=!bench run locally (only failure is the known local Xdebug nesting in BenchAttr::rangeSum)

Documentation

  • Bridge README, FEATURE_PARITY.md, per-folder TODO.md, skills testo-migrate-from-phpunit and testo-test-doubles.

…Unit→Mockery and Mockery→Double sets

feat(bridge-rector): convert PHPUnit mocks onto Mockery
feat(bridge-rector): convert Mockery doubles onto Double
feat(bridge-rector): convert configured and partial mocks, `willReturnMap` and every PHPUnit constraint via predicates
fix(bridge-rector): normalise type names Double's `Argument::type()` would read as classes
fix(skills): let the Rector scaffolder take several sets and find them in the flattened `config/`
docs(skills): document the mock sets

BREAKING CHANGE: `phpunit-to-testo` no longer converts mocks, since the target library is a choice; add `TestoRectorSetList::PHPUNIT_TO_DOUBLE` or `PHPUNIT_TO_MOCKERY` next to it. `CreateMockToDoubleRector` moved to the `Testo\Bridge\Rector\PhpunitToDouble` namespace.

Constraint predicates reproduce PHPUnit's own evaluate(); PhpunitConstraintTest pins verdicts taken from PHPUnit on the edge values.

Assisted-By: Claude Opus 5.5
@roxblnfk
roxblnfk requested a review from a team as a code owner September 24, 2026 19:58
@roxblnfk
roxblnfk merged commit f03ab42 into 1.x Sep 24, 2026
26 of 29 checks passed
@roxblnfk
roxblnfk deleted the feat/rector-mock-sets branch September 24, 2026 21:04
@roxblnfk roxblnfk mentioned this pull request Sep 24, 2026
roxblnfk added a commit that referenced this pull request Sep 25, 2026
…Unit→Mockery and Mockery→Double sets (#351)

feat(bridge-rector): convert PHPUnit mocks onto Mockery
feat(bridge-rector): convert Mockery doubles onto Double
feat(bridge-rector): convert configured and partial mocks, `willReturnMap` and every PHPUnit constraint via predicates
fix(bridge-rector): normalise type names Double's `Argument::type()` would read as classes

BREAKING CHANGE: `phpunit-to-testo` no longer converts mocks, since the target library is a choice; add `TestoRectorSetList::PHPUNIT_TO_DOUBLE` or `PHPUNIT_TO_MOCKERY` next to it. `CreateMockToDoubleRector` moved to the `Testo\Bridge\Rector\PhpunitToDouble` namespace.

Constraint predicates reproduce PHPUnit's own evaluate(); PhpunitConstraintTest pins verdicts taken from PHPUnit on the edge values.

Assisted-By: Claude Opus 5.5
roxblnfk added a commit that referenced this pull request Sep 25, 2026
fix(skills): let the Rector scaffolder take several sets and find them in the flattened `config/`

Assisted-By: Claude Opus 5.5
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