2.4.8 Integration test annotations not working because of phpunit 9->10 upgrade - event management system #39907
Labels
Issue: ready for confirmation
Reported on 2.4.8
Indicates original Magento version for the Issue report.
Triage: Dev.Experience
Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
This is a similar kind of issue to #39463 in that we have code looking to hook into
TestResult
which is a class that no longer exists.In short, I believe all php annotations used in integration tests are no longer functioning as expected. This prevents us from properly writing tests to verify our work.
I have not fully tested all of them, but can verify it for annotations like
The reason for this is that Magento has bumped the phpunit dependency as follows
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.5",
This major version changes the event system, which does not appear to have corresponding fixes in the codebase.
I have been able to reproduce this on a vanilla 2.4.8 installation.
How it works in
2.4.7-p5
/ phpunit^9.5
phpunit would call
$listener->startTest($test)
before each test execution on theTestResult
classhttps://github.com/sebastianbergmann/phpunit/blob/43d2cb18d0675c38bd44982a5d1d88f6d53d8d95/src/Framework/TestResult.php#L435-L443
The magento framework has an eventmanager system which would fire a subsequent event for
startTest
magento2/dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php
Lines 122 to 128 in dc87600
magento2/dev/tests/integration/framework/Magento/TestFramework/EventManager.php
Lines 43 to 52 in dc87600
This would be picked up by the
Annotation/AdminConfigFixture.php
class which would handlestartTest
, and stub in the necessary config valuesmagento2/dev/tests/integration/framework/Magento/TestFramework/Annotation/AdminConfigFixture.php
Lines 104 to 108 in dc87600
How it fails to work in
2.4.8
/ phpunit^10.5
The entire event system has changed, and I cannot see how it is compatible. I do not know how the current integration test fixtures are running on this repository, given that they should also be using phpunit 10 series.
startTest
event exists https://docs.phpunit.de/en/10.5/events.html#teststartTest
https://github.com/magento/magento2/blob/2.4.8/dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php#L122Verification of issue
The phpunit 9 series has
startTest
references, so the magentostartTest
events hook into thatThe phpunit 10 series clearly has no references, so the magento
startTest
events never triggerExample repository
Additionally I have spun up a repository with running integration tests, see https://github.com/convenient/magento-broken-integration-tests-events
It has a test like so
And it works on the

2.4.7-p5
series, but not2.4.8
The actions can be seen here https://github.com/convenient/magento-broken-integration-tests-events/actions/runs/14926109084
The test failure is like
The text was updated successfully, but these errors were encountered: