New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC/Unit Tests] Use phpunit polyfill for deprecated assertRegExp #25635
Conversation
(Standard links)
|
1d1e67d
to
d945bf4
Compare
d945bf4
to
eabb1ac
Compare
Jenkins re test this please |
Those were real fails, mostly. I probably only ran a sample with phpunit8 when I originally set it up just to check that it could work. There are things like tests which don't extend TestCase which might need some massaging if we continue with this route (see https://github.com/Yoast/PHPUnit-Polyfills#supported-ways-of-calling-the-assertions). And then some which I haven't had a chance to look what the problem is. I suppose all the assertRegExp's could just be rewritten as |
One could also add a new method to do the exact same thing... but with a different name! Many premium names are available for the choosing, like |
Hehe. |
😄 Fun fact - that's actually what I did on another repo: https://github.com/totten/git-scan/blob/2022-07-15/tests/GitScan/GitScanTestCase.php#L103-L121 (Edit: Though I'm sure the polyfill projects have more depth than ^^^...) |
UG - I added these to |
just reopening to get the list of fails again |
Put the list at https://lab.civicrm.org/dev/core/-/issues/4188 |
Overview
assertRegExp is deprecated in phpunit 9, but the replacement isn't available yet in phpunit 8. The polyfill fills the gap.
Before
Can't replace deprecated functions yet.
After
Can replace deprecated functions.
Technical Details
The meat of it is the
use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames;
in CiviUnitTestCase. The rest is just find/replace.I expect this will cause (more) tests to fail in the drupal 8 matrix. The way the build works there it doesn't pull in the dev dependencies. I won't rant about composer here just will say that civi is a subproject in that matrix not the root, so dev dependencies need to be pulled in by the build script.
Comments
The original diff I was using for drupal 10 tests also had a fix in CRM_Utils_System::fixUrl for null input, but I've left that out since it doesn't really belong here, and I can't remember offhand what triggered it. I think I was going to go back and try to find out what was passing in null for the url. I don't think it will come up in the run here.