Problem/Motivation
@requires externalCommand is not a supported syntax in PHPUnit 10, and its parser no longer processes it.
The valid types of @requires are describe here, https://docs.phpunit.de/en/10.0/annotations.html#requires.
We can no longer rely on PHPUnit internal Test::parseTestMethodAnnotations() method (which is no longer existing BTW), nor on its new Metadata API, to fetch this information.
Steps to reproduce
Run a build test with PHPUnit 10.
Proposed resolution
My suggestion would be to replace @requires externalCommand annotation with a static method to be implemented in the concrete tests.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
mondrakeComment #3
longwaveSome thoughts from Slack summarised here:
We introduced this three years ago as a generic solution but in fact we only use it four times, each to check that Composer is available.
I suggest moving the check into ComposerBuildTestBase and making ComposerValidateTest extend that, or perhaps adding the check to ComposerIntegrationTrait.
The more generic solution that follows PHPUnit would be to introduce a
#[RequiresExternalCommand]attribute similar to https://docs.phpunit.de/en/10.0/attributes.html#skipping-tests but given we haven't needed this for anything else I suspect this is overkill and ExternalCommandRequirementsTrait can be removed.Comment #4
mondrakeThanks! I'm working on a solution based on a simple requirements check method.
Comment #6
wim leersTo add to #3: it seems nothing in contrib uses this: http://grep.xnddx.ru/search?text=%40requires+externalCommand&filename=*T...
Comment #7
mondrakeComment #8
mondrakeComment #9
smustgrave commentedDo these instances need to be replaced too?
Comment #10
mondrakeThe ExternalCommandRequirementTest ones no, because they serve the purpose of checking the deprecation. But the ComponentsTaggedReleaseTest probably yes - although it looks like the check was never done for that test...
Comment #11
mondrakeRebased and fixed
ComponentsTaggedReleaseTest.Comment #12
smustgrave commentedLGTM.
Comment #13
longwaveAs we only ever require Composer I think we can just make this even simpler?
You just add this trait to any class and it automatically skips if Composer is not available?
Comment #14
mondrakeI have some doubts we can skip a test through a
@beforeClassannotated method, but I got the gist of this. Need some trials.Comment #15
longwaveI did a very rough trial locally and it seemed to work, so I am hopeful.
Comment #16
mondrakeOK thanks, I will work on this.
Comment #17
mondrakeCan't add a deprecation trigger for
ExternalCommandRequirementsTraitas it would fire during test discovery when the bridge is not yet capturing deprecations(*). So added a trigger to all the trait's methods instead.(*) That's why things like these should live in the TestTools namespace, as the new trait - so that they do not mix up with the tests themselves.
Comment #18
longwaveLooks great! I updated the change record with documentation for the new trait.
Comment #22
catchCommitted/pushed to 11.x, thanks! (ignore the 10.1 commits...)
Comment #25
quietone commentedPublished the change record.