Update test stack: migrate to Foundry 2 and PHPUnit 11 (Case 212955) - #25
Merged
Conversation
Foundry 1 cannot run on Symfony 8, so it must be replaced before the final bump; on the interim Symfony 7 this can happen in isolation. Foundry 2 removed the ModelFactory base class — rewrite the four test factories onto PersistentProxyObjectFactory: getDefaults() → defaults(), getClass() → class() (public static), initialize() return type self → static. Because Foundry 2 requires PHPUnit >= 9.5 (and Foundry 1 does not run on PHPUnit 11), the PHPUnit 8.5 → 11 bump and the phpunit.xml schema update ride along in the same package. Two additional fixes needed to make the suite green on PHPUnit 11: - buildForm() and configureOptions(): add missing `: void` return type to the five form types that declared them without one (EmailAddressType, HoneypotType, StartRegistration\Type, EditRegistration\Type, DeleteRegistration\Type). mapDataToForms() and mapFormsToData() were already typed correctly; Command::execute(), the FlashBag→RequestStack replacement, and the routing 'attribute' switch were already in place from Package E. - DetermineAppsSubclassHelper: skip eval()'d PHPUnit test-double classes when scanning get_declared_classes() for a RecipientInterface subclass. PHPUnit 11 auto-generates named stub classes (via eval()) for interface return types — these were picked up before App\Recipient, causing RecipientFactoryTest to fail in the full suite. PHP reports a synthetic filename for eval()'d code rather than false, so the guard uses is_file() to confirm a real file exists on disk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Foundry 1 cannot run on Symfony 8, so it must be replaced before the final bump; on the interim Symfony 7 this can happen in isolation. Foundry 2 removed the ModelFactory base class — rewrite the four test factories onto PersistentProxyObjectFactory: getDefaults() → defaults(), getClass() → class() (public static), initialize() return type self → static. Because Foundry 2 requires PHPUnit >= 9.5 (and Foundry 1 does not run on PHPUnit 11), the PHPUnit 8.5 → 11 bump and the phpunit.xml schema update ride along in the same package.
Two additional fixes needed to make the suite green on PHPUnit 11:
: voidreturn type to the five form types that declared them without one (EmailAddressType, HoneypotType, StartRegistration\Type, EditRegistration\Type, DeleteRegistration\Type). mapDataToForms() and mapFormsToData() were already typed correctly; Command::execute(), the FlashBag→RequestStack replacement, and the routing 'attribute' switch were already in place from Package E.