Skip to content

fix(rector): preserve string assertion call contracts - #396

Open
ichinya wants to merge 2 commits into
php-testo:1.xfrom
ichinya:feat/390-string-assertion-contracts
Open

ichinya wants to merge 2 commits into
php-testo:1.xfrom
ichinya:feat/390-string-assertion-contracts

Conversation

@ichinya

@ichinya ichinya commented Oct 15, 2026 •

Copy link
Copy Markdown

PHPUnit string assertion migration can produce invalid named calls, reject values accepted through weak coercion, reorder argument side effects and change a used assertion's result.

Map PHPUnit's source parameter names explicitly. Safe standalone calls with native string arguments keep the short fluent form. Other supported string calls use a typed void closure to preserve named binding, caller weak/strict coercion, message validation, evaluation order and null results. Unsupported named/unpacked call shapes stay available for manual migration.

Keep runtime input fixtures beside the feature tests and verify concise named output in a co-located golden fixture. Execute the full migration set and the converted code in a child process. Check every converted test's outcome, assertion count and strict TypeError class; include a required failing assertion so a dropped assertion cannot pass the regression suite.

Validation:

  • PHP 8.2.34, 8.3.35 and 8.5.11: all 929 relevant checks pass on each runtime (362 Rector fixtures, 171 harness unit tests, 2 runtime feature tests and 394 Assert tests). PHP 8.2 was explicitly tested.
  • PHP 8.5 full regular suite: passed, 2928 tests and 5851 assertions; no failures or errors, one flaky and two skipped.
  • The actual Rector CLI with real PHPUnit reflection matches all 17 native cases from PHPUnit 12.5.39 and 13.4.2 by outcome and assertion count: 13 pass, one required assertion failure and three strict TypeErrors; 24 assertions total.
  • Changed-file CS Fixer, Composer validation and git diff checks pass.
  • Combined with fix(rector): leave custom assertion methods unchanged #395: merges without conflicts and the full regular suite passes (2930 tests, 5853 assertions, no failures or errors).

Part of #390. PHPUnit method ownership is handled in #395. Both PRs target 1.x independently; review #395 first.

Map PHPUnit string parameter names and retain caller weak/strict coercion,
message validation, evaluation order and void results through typed closures.
Keep safe standalone calls concise and unsupported bindings available for
manual migration.

Execute converted weak and strict fixtures through the CLI in child processes
and check each test's outcome and assertion count.

Refs php-testo#390

Assisted-By: GPT-6 <noreply@anthropic.com>
Keep weak and strict runtime inputs beside their feature tests instead of
storing a second copy of the generated PHP. Retain all per-test outcomes,
assertion counts and strict TypeError checks.

Cover concise named calls in the existing contains fixture so the generated
short form still has a golden check.

Refs php-testo#390

Assisted-By: GPT-6 <noreply@anthropic.com>
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