Closed (fixed)
Project:
Drupal core
Version:
main
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
2 Jun 2025 at 14:02 UTC
Updated:
22 Apr 2026 at 07:05 UTC
Jump to comment: Most recent
Comments
Comment #3
mondrakeComment #4
mondrakeComment #5
mondrakeComment #6
mondrakeMerge MR with MRs from #3530453: Remove deprecated use of Assert::isType() and #3550292: Test cleanup for PHPUnit 12 - round 2
Comment #7
mondrakeGreen! The MR now includes #3530453: Remove deprecated use of Assert::isType(), #3550292: Test cleanup for PHPUnit 12 - round 2.
Comment #8
mstrelan commentedRegarding #[RunTestsInSeparateProcesses] and requiring it for contrib, I noticed you've used rector for the core conversions, but I think there is a lower barrier to entry for phpcs and phpcbf since it's already installed in drupal/core-dev. I had AI generate a fixable phpcs rule, tested it on a contrib module and it worked. Should we consider opening a coder issue for this?
Comment #9
mondrake#8 sure it would make sense. Can PHPCS selectively detect that the test class inherits from one of KernelTestBase or BrowserTestBase? Only those should have the attribute, Unit and Build tests do not need it, at least by default.
Comment #10
mstrelan commentedYes the poc I did checked the parent class(es).
Comment #11
mondrakeComment #12
mondrakeComment #13
quietone commentedWe are trying to use tags to identify version, so removing from title. The 'Major version only' seems sufficient?
Comment #14
gábor hojtsyWhat is this currently postponed on? This is not clear to me. Being a Drupal 12 requirement, would be good to know :)
Comment #15
mondrake#14 the main blocker is #3561671: [meta] Refactor tests to use stubs instead of mocks where mocks do not configure expectations at the moment.
Comment #16
catch@gabor #3561671: [meta] Refactor tests to use stubs instead of mocks where mocks do not configure expectations which is linked from the issue summary is the main blocker.
Annotations to attributes is fully done at this point (as far as we know).
Not sure if there are other smaller changes too but probably easier to refresh the MR once the mock/stub issues are in for any stragglers.
Comment #17
gábor hojtsyThanks, adding postponed-on issue to the top of the issue summary to make this clear :)
Comment #18
quietone commentedComment #19
dcam commentedI've been working on fixing the mock object notices in the core library tests. I think there were over 1500 notices when I started. I'm down to under 300 at the moment. My plan is to start opening more issues and committing some of the work in the next day or two.
Comment #20
mondrakeGetting close.
Comment #21
mondrakeThere's only one failing test once #3581058: Convert expectation-less test mocks to stubs - cleanup is included here. I think this MR is reviewable now.
Comment #22
mondrakeAll tests green on all db platforms.
Comment #23
dcam commentedThe last mock object fix issue has been committed.
Comment #24
dcam commentedThere's a to-do in phpstan.neon.dist to remove the disallowed method call for any() since it will be detected as deprecated by normal PHPStan checks. I can remove it, if you'd prefer for me to do it. But I didn't want to jump in and make changes while you're actively pushing commits, @mondrake.
Comment #25
mondrake@dcam I will be afk for next 3 days so if you want to move this forward, feel free! Thanks for checking.
Comment #26
smustgrave commentedLeft a few comments/questions on the MR.
Comment #27
smustgrave commentedAll feedback appears to be addressed! I resolved the threads I opened and I believe this one is good to go!!!
Comment #28
mondrakeIMHO we should get ahead and just remove support for PHPUnit 11 here. It’s been painful to keep concurrent 10/11 support within D11 lifecycle, can’t see a reason for such a pain when going into a new Drupal major. Especially if we target even another bump to PHPUnit 13.
Comment #29
dcam commentedMakes sense to me. I can start the work on it, though I don't know off-hand where all the BC layers are at. I'll do my best.
It will need a change record. Tagging.
Comment #30
mondrakeI think we also need a CR, tagging
Comment #31
mondrake#29 #30 small (or was great? 😀) minds think alike - xpost
Comment #32
smustgrave commentedBummer thought we were close but makes sense to drop 11.
Ping me if you want a quick review to help keep moving it
Comment #33
mondrake#29 OTOMH it should be sufficient to remove the version dependent compatibility trait, and check if there are occurrences of runnerversion::getMajor() that target 11 or below.
Then update the composer.json constraints and run
composer update —lockto get a freah composer.lockComment #34
dcam commentedOk. I will do that.
I came back to ask if we want to remove the custom PHPStan rules forbidding PHPUnit annotations. I didn't know if the preference would be to purge everything or to leave those rules so any code in violation gets caught early by automated tests. I'd lean toward keeping them, at least until Drupal 13.
Comment #35
smustgrave commentedCould it be a follow up? Guess it depends how much it would blow the MR up.
Comment #36
mondrake#34 good point. Annotations in PHPUnit 12 would just be no-ops, or a relic of the past if you wish. But PHPStan would flag that for older MRs in the pipeline, and for contrib if they use the rules in their config, which I agree would be a good thing for a bit longer. I think we should keep them for D12 cycle to smoothen the transition, I feel like contrib will take a while to comply.
Comment #37
dcam commentedYes, there's no reason we couldn't defer removing them.
Comment #38
dcam commentedExactly. If we leave them in, then there's less chance of something going wrong for someone somewhere.
Comment #39
dcam commentedThere's one test failure that I think is random.
I added the change record. I opted to link to the original CR about adding PHPUnit attribute support instead of copying and pasting all that information. That way there's a single source for that information. I also decided to mention that we're leaving the PHPStan rules in place to encourage people to use them for detecting the obsolete annotations.
Comment #40
smustgrave commentedStarted a new pipeline since we can't re-run
Comment #41
smustgrave commentedHad to re-run like 3 times but finally all green. Kept just triggering a new random each time.
Comment #42
mondrakeThanks. How about a follow up to remove the PHPUnit compatibilty trait? We have been having that completely empty for PHPUnit 11, now 12, and likely in 13 in the future. We may readd it in case in the future is needed, but for now it is just unnecessary maintenance burden.
Comment #43
catchCommitted/pushed to main, thanks!
A follow-up to remove the compatibility trait sounds good.
Comment #47
smustgrave commentedI published the CR
Comment #48
mondrakeFiled #3583606: Fix usage of with*() without expects() in mocks - round 1
Comment #49
mondrake