You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 93ff20a
Browse filesBrowse the repository at this point in the historyBrowse files
Install the right container before every test and data provider on PHPUnit 9 too
PHPStanPHPUnitExtension implements the PHPUnit >= 10 extension interface and is
registered through <extensions><bootstrap>, which PHPUnit 9 rejects outright
("Element 'bootstrap': This element is not expected. Expected is ( extension )").
The "Tests with old PHPUnit" jobs therefore ran without its two subscribers, so
nothing made a data provider or a test see its own test class's container - and
because ParaTest reuses one worker process for many test files, whatever
container the previous file installed stayed installed.
That is what flaked IntersectionTypeTest::testIsAcceptedBy on the 8.1 jobs: a
bleeding edge test file left BleedingEdgeToggle on, dataIsAcceptedBy() built its
ConstantArrayTypes sealed (the constructor reads the toggle), dataGetEnumCases()
then called createReflectionProvider() and switched the toggle back off, and
every data set expecting Maybe came out No. Reproduced deterministically with
paratest --runner WrapperRunner -p 1 -c <config without the extension>
over a bleeding edge test file followed by IntersectionTypeTest. The same gap
made VerbosityLevelTest and 29 other files fail with
MissingStaticAccessorInstanceException whenever they were the first file a
worker picked up.
setUp() now always installs the test class's own container, tearDownAfterClass()
restores the base one for the next file's data providers, and the bootstrap
installs it for the first file's - which makes
$reinitializeContainerBeforeEachTest redundant - and InitContainerBeforeTestSubscriber
too, so setUp() is now the one mechanism for tests on every PHPUnit version.
InitContainerBeforeDataProviderSubscriber stays: data providers run while the suite
is being built, and a single-process PHPUnit >= 10 run calls every class's providers
before the first test, so a provider that installs its own container would otherwise
leak it into the next class's providers. PHPUnit 9 has no such hook, so a data
provider of a test class whose container is not the base one still has to ask for
it itself there, the way TypeGetFiniteTypesTest now does.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019isZYNh3Zms6xGKGGXqxgp
0 commit comments