Problem/Motivation

Child of #3110543: [meta] Support PHPUnit 9 in Drupal 9, this is to effectively add support for PHPUnit 9. This also resolves half of the 29 dependency issues when attempting to make Drupal 9 core compatible with PHP 8. See #3109885: [meta] Ensure compatibility of Drupal 9 with PHP 8.0 (as it evolves).

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Drupal 9 now uses PHPUnit 9 to run tests on PHP versions higher than PHP 7.3. This prepares Drupal core to support PHP 8 when it is released, but may require some small changes to tests in contributed or custom modules. See the change record for more details.

CommentFileSizeAuthor
#111 3127141-111.patch38.99 KBalexpott
#111 pseudo-interdiff.txt3.46 KBalexpott
#100 3127141-100.patch38.67 KBmondrake
#100 interdiff_97-100.txt1.93 KBmondrake
#98 interdiff_96-97.txt2.7 KBmondrake
#98 3127141-97.patch38.76 KBmondrake
#96 3127141-96.patch38.72 KBmondrake
#96 interdiff_93-96.txt3.83 KBmondrake
#93 interdiff_89-93.txt1.04 KBmondrake
#93 3127141-93.patch38.92 KBmondrake
#89 interdiff.3127141.88-89.txt481 byteslongwave
#89 3127141-89.patch38.78 KBlongwave
#88 3127141-88.patch38.19 KBmondrake
#88 interdiff_86-88.txt690 bytesmondrake
#86 3127141-86.patch37.94 KBmondrake
#86 interdiff_85-86.txt4.86 KBmondrake
#85 interdiff_83-85.txt8.45 KBmondrake
#85 3127141-85.patch34.27 KBmondrake
#83 interdiff_82-83.txt1.51 KBmondrake
#83 3127141-83.patch27.24 KBmondrake
#82 3127141-82.patch25.85 KBmondrake
#78 3127141-78-for-review-do-not-test.txt25.73 KBmondrake
#78 3127141-78.patch40.33 KBmondrake
#74 3127141-74.patch33.18 KBravi.shankar
#66 3127141-66.patch33.17 KBmondrake
#66 interdiff_62-66.txt1.09 KBmondrake
#64 interdiff_62-64.txt857 bytesmondrake
#64 3127141-64.patch32.92 KBmondrake
#62 interdiff_56-62.txt1 KBmondrake
#62 3127141-62.patch32.08 KBmondrake
#60 3127141-60.patch31.74 KBSuresh Prabhu Parkala
#56 3127141-56.patch31.61 KBmondrake
#55 3127141-55.patch32.25 KBalexpott
#53 3127141-53.patch32.03 KBmondrake
#51 3127141-51.patch33.56 KBmondrake
#51 interdiff_50-51.txt823 bytesmondrake
#50 interdiff_48-50.txt1.94 KBmondrake
#50 3127141-50.patch33.07 KBmondrake
#49 3127141-48.patch31.13 KBmondrake
#48 interdiff_47-48.txt1.99 KBmondrake
#47 3127141-47.patch30.56 KBmondrake
#41 3127141-41.patch30.21 KBmondrake
#41 interdiff_39-41.txt1.18 KBmondrake
#39 interdiff_35-39.txt636 bytesmondrake
#39 3127141-39.patch29.49 KBmondrake
#35 3127141-35.patch29.33 KBmondrake
#30 interdiff_28-30.txt462 bytesmondrake
#30 3127141-30.patch29.78 KBmondrake
#28 3127141-28.patch29.03 KBmondrake
#25 interdiff.3127141.22-25.txt6.02 KBlongwave
#25 3127141-25.patch30.66 KBlongwave
#22 interdiff_19-22.txt2.96 KBmondrake
#22 3127141-22.patch32.05 KBmondrake
#19 3127141-19.patch30.94 KBmondrake
#19 interdiff_18-19.txt854 bytesmondrake
#18 3127141-18.patch30.11 KBmondrake
#18 interdiff_16-18.txt5.08 KBmondrake
#16 3127141-16.patch24.28 KBmondrake
#16 interdiff_15-16.txt3.17 KBmondrake
#15 3127141-15.patch21.91 KBmondrake
#10 interdiff_8-10.txt1.48 KBNeslee Canil Pinto
#10 3127141-10.patch14.75 KBNeslee Canil Pinto
#8 3127141-8.patch14.12 KBmondrake
#5 3127141-5.patch14.21 KBmondrake
#5 interdiff_4-5.txt1.15 KBmondrake
#4 interdiff_2-4.txt2.33 KBmondrake
#4 3127141-4.patch13.76 KBmondrake
#2 3127141-2.patch11.43 KBmondrake
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
Issue tags: +PHPUnit 9
FileSize
11.43 KB

Initial patch. We're not that far, we basically only miss the remaining issues to replace the usage of reflection-enabled PHPUnit methods, plus silencing the new warnings actually being added in PHPUnit 9.

Status: Needs review » Needs work

The last submitted patch, 2: 3127141-2.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
FileSize
13.76 KB
2.33 KB

Converting some calls to deprecated methods in tests that extend directly from PHPUnit's TestCase.

mondrake’s picture

With some version dependency dance to allow both PHPUnit 8 and 9 results printers.

The last submitted patch, 4: 3127141-4.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 5: 3127141-5.patch, failed testing. View results

mondrake’s picture

longwave’s picture

Nice work!

+++ b/core/tests/Drupal/Tests/Traits/PHPUnit8Warnings.php
@@ -26,6 +26,14 @@
+    // PHPUnit 9.

We probably want to rename this trait to just e.g. PhpUnitWarnings now?

Neslee Canil Pinto’s picture

Status: Needs work » Needs review
FileSize
14.75 KB
1.48 KB

Changed as per #9

mondrake’s picture

#9 yes, that trait is going to stay around, better have a more permanent naming...

mondrake’s picture

@Neslee what @longwave means is to rename the trait and all its usages. For example from PHPUnit8Warnings To PhpUnitWarningsCompatibiltyTrait

Status: Needs review » Needs work

The last submitted patch, 10: 3127141-10.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Postponed

Let’s wait for the PHPUnit8 deprecation issues to land, first.

mondrake’s picture

mondrake’s picture

Status: Postponed » Needs review
FileSize
3.17 KB
24.28 KB

We're in home run :)

Status: Needs review » Needs work

The last submitted patch, 16: 3127141-16.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
FileSize
5.08 KB
30.11 KB

PHPUnit 9 probably changed something in the checking of assertContains of arrays - now the sequence of the keys in the array matters, so prior to calling assertContains in nested arrays we need to ensure sorting of keys...

mondrake’s picture

Also, type checking has become strict.

The last submitted patch, 18: 3127141-18.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 19: 3127141-19.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
FileSize
32.05 KB
2.96 KB

Simplified the failing test, and made changes to allow running on PHP 7.3

longwave’s picture

Instead of sorting in #18 can we improve the assertions? We know the array key in at least some of the cases, I think?

mondrake’s picture

#24 I do not see anything wrong in sorting before asserting. Actually for equality comparison there’s a assertEqualsCanonicalizing in pure PHPUnit... but no such thing as an assertContainsCanonicalizing AFAICS.

longwave’s picture

We don't need to sort the arrays or change MessengerTest - we can just use assertContainsEquals() which is less strict.

mondrake’s picture

Good catch @longwave!

Unfortunately that method is not documented in the PHPUnit docs, although it’s clear that it is supported

https://thephp.cc/news/2019/02/help-my-tests-stopped-working

https://github.com/sebastianbergmann/phpunit/issues/3511

mondrake’s picture

Filed issue upstream reagrding the missing documentation,

https://github.com/sebastianbergmann/phpunit/issues/4181

mondrake’s picture

Rerolled.

EDIT - note I've been using a -M20% argument for git diff to allow comparing the PHPUnitWarning trait

Status: Needs review » Needs work

The last submitted patch, 28: 3127141-28.patch, failed testing. View results

mondrake’s picture

Looks like PHPUnit 9.1.2 broke Symfony's PHPUnit Bridge. Pros and cons of getting closer to the edge of dependencies'. Let's just see this.

longwave’s picture

Upstream issue to follow for phpunit-bridge is https://github.com/symfony/symfony/issues/36499

mondrake’s picture

Nevertheless, I think we should avoid a caret constraint for PHPUnit in composer.json, and work with ranges instead. Then extend the range only when tested OK. PHPUnit is rather aggressive on changing its internals (not blaming, it has pros and cons), and #31 is a smoking gun example of possible impacts.

mondrake’s picture

longwave’s picture

Symfony fixed the issue on their side so I think we have to wait for new Symfony releases and then bump our dependency on the phpunit-bridge.

mondrake’s picture

Rerolled.

mondrake’s picture

#34 that would exclude the faulty 9.1.2 PHPUnit version too, nevertheless I think we should make it explicit ourselves either in the require-dev or the conflict sections in composer.json

longwave’s picture

Symfony already added a conflict with PHPUnit 9.1.2 and kept a BC layer for <9.1.2 so I think we just have to bump the version of phpunit-bridge and we are all OK.

mondrake’s picture

Assigned: Unassigned » mondrake
Status: Needs review » Needs work

Symfony 4.4.8 is out with the fix for #30.

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Needs work » Needs review
FileSize
29.49 KB
636 bytes

Reuqesting the latest phpunit-bridge version, albeit not updating the lock file, yet.

Status: Needs review » Needs work

The last submitted patch, 39: 3127141-39.patch, failed testing. View results

mondrake’s picture

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Works for me, let's see what core committers think.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -317,7 +317,7 @@ public static function upgradePHPUnit(Event $event) {
-    // If the PHP version is 7.3 or above and PHPUnit is less than version 7
+    // If the PHP version is 7.4 or above and PHPUnit is less than version 9

@@ -339,7 +339,7 @@ public static function upgradePHPUnit(Event $event) {
-    return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.3') >= 0 && version_compare($phpunit_version, '7.0') < 0);
+    return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.4') >= 0 && version_compare($phpunit_version, '9.0') < 0);

+++ b/core/scripts/run-tests.sh
@@ -149,7 +149,7 @@
-  simpletest_script_print_error("PHPUnit testing framework version 7 or greater is required when running on PHP 7.3 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this.");
+  simpletest_script_print_error("PHPUnit testing framework version 9 or greater is required when running on PHP 7.4 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this.");

I'm not a huge fan of this. PHPUnit 8 supports PHP 7.4 so we're enforcing an upgrade that's not necessary.

+++ b/composer.json
@@ -21,7 +21,7 @@
-        "phpunit/phpunit": "^8.4.1",
+        "phpunit/phpunit": "^8.4.1 || <9.1.2",

+++ b/composer/Metapackage/DevDependencies/composer.json
@@ -16,7 +16,7 @@
-        "phpunit/phpunit": "^8.4.1",
+        "phpunit/phpunit": "^8.4.1 || ^9",

This doesn't look right.

mondrake’s picture

Thanks @alexpott

Re. 1 what's next then? PHP 8.0 is still way to go. Moving D9 straight to PHPUnit9 seemed to me too long a step from D8 (which is still supporting PHPUnit6). IMHO testing PHP 7.3 on PHPUnit8 and PHP 7.4 on PHPUnit9 could be a compromise to start work on migrating the test assertions from Simpletest to PHPUnit native (and recent) ones, while at the same time keeping an eye on further evolutions of PHPUnit, starting earlier when possible any adjustment work.

Re. 2 it's not, and it's been corrected in #41.

longwave’s picture

I think I agree that until we have a PHP 8 to test on, testing PHP 7.3 on PHPUnit 8 and PHP 7.4 on PHPUnit 9 seems like a good compromise. Therefore the code in Drupal\Core\Composer\Composer::upgradePHPUnit does the right thing to get both of these tested on the testbot. However, the message in run-tests.sh is not strictly true - PHPUnit 9 is not strictly required on PHP 7.4, maybe we need to reword this?

The other option is just postpone this entirely until PHP 8 forces us to upgrade, I guess. We have still fixed all the deprecations to date - having said that there may be more to come, and it would be good to keep on top of them.

mondrake’s picture

Issue tags: +Needs reroll
mondrake’s picture

mondrake’s picture

FileSize
1.99 KB
mondrake’s picture

mondrake’s picture

mondrake’s picture

FileSize
823 bytes
33.56 KB
mondrake’s picture

Status: Needs work » Needs review

An alternative for #43.1 could be not to upgrade to PHPUnit 9 based on the PHP verison, here. Just loosen the composer.json constraint. Then, in a NO-COMMIT issue, kept in RTBC, just add a container command to upgrade to PHPUnit 9, so that a regular run can report failures. Feels fragile, but also the only possibility I see here ATM (I saw something like for some time for hi-lo dependencies testing).

mondrake’s picture

FileSize
32.03 KB

Reroll.

alexpott’s picture

Priority: Normal » Critical

This is a critical tasks because it blocks PHP 8 adoption.

alexpott’s picture

Rerolled... git took care of it with a 3 way merge.

mondrake’s picture

Status: Needs review » Needs work

The last submitted patch, 56: 3127141-56.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
mondrake’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
Suresh Prabhu Parkala’s picture

Status: Needs work » Needs review
FileSize
31.74 KB

Re-rolled patch please review!

Status: Needs review » Needs work

The last submitted patch, 60: 3127141-60.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
32.08 KB
1 KB

The at() matcher has been deprecated. It will be removed in PHPUnit 10. Please refactor your test to not rely on the order in which methods are invoked.

Added the above to silenced warnings.

Status: Needs review » Needs work

The last submitted patch, 62: 3127141-62.patch, failed testing. View results

mondrake’s picture

PHPUnit 9.5.3 removes 'phpunit/php-token-stream' from its dependencies.

mondrake’s picture

Status: Needs work » Needs review
mondrake’s picture

longwave’s picture

Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!

Should we look to fix this here?

mondrake’s picture

#67 we can try, but we need to keep it compatible with PHPUnit 8...

longwave’s picture

Ah yeah, it will still give the warning if the XML doesn't validate, and we need to keep the old elements for BC, so we might as well wait until we have a minimum of PHPUnit 9.

I tried this locally anyway and ran into https://github.com/sebastianbergmann/phpunit/issues/4419

longwave’s picture

Status: Needs review » Reviewed & tested by the community

In which case back to RTBC on this, and core committers can decide whether we only require PHPUnit 9 in PHP 8 or allow it in 7.4.

xjm’s picture

@catch brought this up to the committer team -- I'd like to have a think about it, so tagging for RM review.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The test fail on #66 seems to show we have a problem on PHP 7.3?

Also I think we should block this on #3142267: Allow the full list of deprecations from PHPUnit8Warning to respect the --suppress-deprecations behavior on DrupalCI - that changes the PHPUnit8Warnings class to trigger deprecation messages so we then only have to maintain a single list of technical debt in \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations() - at the very least this patch should make the same change.

mondrake’s picture

The test fail on #66 seems to show we have a problem on PHP 7.3?

We would have to update the content-hash in the composer.lock file, to reflect the change in require-dev constraints, but I am refraining to do so since the patch would then require continuous rerolls. When you run the phpunit-update script (i.e. when testing on 7.4 ATM) this is not failing since the composer.lock file hash gets refreshed as part of the build.

ravi.shankar’s picture

Patch #66 didn't apply anyomore on Drupal 9.1.x, so here I have added reroll of patch #66.

mondrake’s picture

Status: Needs work » Postponed

Let’s postpone per #72 then.

mondrake’s picture

Issue tags: +PHP 8.0
mondrake’s picture

mondrake’s picture

Huh, #78 apparently fails since some test classes use ::prophesize in data provider methods and the deprecation cannot be silenced in that case?

(apart from the failures of PhpUnitWarningsTest that are expected given #3142267-58: Allow the full list of deprecations from PHPUnit8Warning to respect the --suppress-deprecations behavior on DrupalCI)

Gábor Hojtsy’s picture

Issue summary: View changes

Wow, this resolves half of the 29 dependency issues when attempting to make Drupal 9 core compatible with PHP 8. (#3109885: [meta] Ensure compatibility of Drupal 9 with PHP 8.0 (as it evolves))

andypost’s picture

Status: Postponed » Needs work

Blocker commited

mondrake’s picture

Status: Needs work » Needs review
FileSize
25.85 KB

#78 for review patch, renamed.

mondrake’s picture

Let's see if we can require phpspec/prophecy-phpunit in the drupal-phpunit-upgrade, and start using the trait.

mondrake’s picture

Assigned: Unassigned » mondrake

I think we need to bring back our old friend PhpunitCompatibilityTrait from D8.9, to enable PHPUnit version dependent shims. See #3142267-62: Allow the full list of deprecations from PHPUnit8Warning to respect the --suppress-deprecations behavior on DrupalCI.

mondrake’s picture

mondrake’s picture

Skipping all tests in PhpUnitWarningsTest when executed under PHPUnit9. I suggest to leave adding back FC shims, where possible, to follow-ups. Added the PhpUnitCompatibilityTrait, which is imported in all base classes.

mondrake’s picture

Assigned: mondrake » Unassigned
mondrake’s picture

longwave’s picture

To update the hash you can run composer update --lock and it will update the hash but leave the packages alone.

alexpott’s picture

+++ b/core/modules/migrate/tests/src/Unit/MigrateStubTest.php
@@ -22,6 +23,8 @@
 class MigrateStubTest extends TestCase {

This should be extending use Drupal\Tests\UnitTestCase; and not the Phpunit class. It's a test in a module and there's no reason to not extend the Drupal base class.

mondrake’s picture

#90 is it in scope here or a follow-up?

alexpott’s picture

I think it is in scope - the changes necessary to the test system show that that test is not inheriting from the correct class.

alexpott’s picture

I've reviewed all the component test changes are it looks like a few changes can be made.

  1. +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
    @@ -8,6 +8,8 @@
    +  use Drupal\Tests\Traits\PhpUnitWarnings;
    
    @@ -24,6 +26,9 @@
    +    use PhpUnitWarnings;
    

    This is not necessary here.

  2. +++ b/core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php
    @@ -4,6 +4,7 @@
    +use Drupal\Tests\Traits\PhpUnitWarnings;
    
    @@ -14,6 +15,8 @@
    +  use PhpUnitWarnings;
    
    +++ b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php
    @@ -5,6 +5,7 @@
    +use Drupal\Tests\Traits\PhpUnitWarnings;
    
    @@ -13,6 +14,8 @@
    +  use PhpUnitWarnings;
    

    Should be use PhpUnitCompatibilityTrait; instead.

  3. +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
    @@ -133,6 +133,18 @@ public static function getSkippedDeprecations() {
    +      'PHPUnit\\Framework\\TestCase::prophesize() is deprecated and will be removed in PHPUnit 10. Please use the trait provided by phpspec/prophecy-phpunit.',
    
    +++ b/core/tests/Drupal/Tests/Traits/PhpUnitWarnings.php
    @@ -37,6 +37,17 @@
    +    'PHPUnit\\Framework\\TestCase::prophesize() is deprecated and will be removed in PHPUnit 10. Please use the trait provided by phpspec/prophecy-phpunit.',
    

    Now we're using the trait I don't think we need this message here anymore.

alexpott’s picture

Status: Needs review » Needs work

For #94

mondrake’s picture

Status: Needs work » Needs review
FileSize
3.83 KB
38.72 KB

Addresses #94, thanks.

#94.3 - we can remove from the deprecation silencers, but not from the PhpUnitWarnings trait unless we accept contrib to fail with PHPUnit warnings.

alexpott’s picture

we can remove from the deprecation silencers, but not from the PhpUnitWarnings trait unless we accept contrib to fail with PHPUnit warnings.

First thought was good point. But then I realised that our base test classes are all using the compatibility trait and therefore we should be able to remove it. We don't support contrib / custom not extending from our base classes.

mondrake’s picture

mondrake’s picture

Status: Needs review » Needs work

#97 to be addressed

longwave’s picture

Status: Needs review » Reviewed & tested by the community

It looks like all review points have been addressed.

mondrake’s picture

Title: Support PHPUnit 9 optionally in Drupal 9, while keeping support for ^8.4 » Require PHPUnit 9 for PHP 7.4+, while keeping support for PHPUnit 8.4 in PHP 7.3

Let's be clear.

mondrake’s picture

Filed #3174200: Use PHPUnit-bridge polyfills for forward compatibility layer as a possible follow-up, for discussion.

alexpott’s picture

Title: Require PHPUnit 9 for PHP 7.4+, while keeping support for PHPUnit 8.4 in PHP 7.3 » Use PHPUnit 9 for PHP 7.4+, while keeping support for PHPUnit 8.4 in PHP 7.3

Re #102 I don't think that is clear actually. PHPUnit 9 is not necessary for testing on PHP 7.4 - it is for PHP 8.0. We don't require PHPUnit 9 to run tests on PHP 7.4 - if you use the phpunit runner.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 100: 3127141-100.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Looks like a random JS fail

catch’s picture



+++ b/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php
+++ b/core/modules/system/tests/src/Kernel/Entity/EntityReferenceSelectionReferenceableTest.php
@@ -126,7 +126,7 @@ public function testReferenceablesWithNoLabelKey($match, $match_operator, $limit

@@ -126,7 +126,7 @@ public function testReferenceablesWithNoLabelKey($match, $match_operator, $limit
       // entity labels.
       // @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::getReferenceableEntities()
       $item = is_string($item) ? Html::escape($item) : $item;
-      $this->assertContains($item, $referenceables[$this->bundle]);
+      $this->assertContainsEquals($item, $referenceables[$this->bundle]);
     }

We probably could have done this in a spin-off issue to make the diff here smaller, but it doesn't really hurt. The method is already available to contrib modules to do the same thing so not much we can do about it ourselves.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

I think this needs reroll since #3064854: Allow Twig templates to use front matter for metadata support has just changed the content-hash in the composer.lock file.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

This is fine. That issue changed the path reference hash - it's not the same thing.

mondrake’s picture

Issue tags: -Needs reroll

Ah, yes. Thanks @alexpott

alexpott’s picture

mondrake’s picture

See... I was obviously foreseeing that :)

catch’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs release manager review

Went over this one more time with a release manager eye, and decided we need a change record, which I've added here: https://www.drupal.org/node/3176567

I think this is in good shape and should not disrupt many contrib tests, if at all, as well as us having no choice due to PHPUnit and PHP's release cycle. So... committed 74fbb0a and pushed to 9.1.x. Thanks!

  • catch committed 74fbb0a on 9.1.x
    Issue #3127141 by mondrake, longwave, alexpott, Neslee Canil Pinto,...
catch’s picture

Forgot to say there are a few changes for @expectedDeprecation vs. ::expectDeprecation() here, however I left them out of the change record because we're already addressing those changes in #3172438: Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead..

mondrake’s picture

From the CR:

::assertContains() now compares the order of arrays, and tests may begin to fail if ordering doesn't match. PHPUnit already provides the more permissive ::assertContainsEquals() so tests can be updated to use this without breaking PHP 7.3 compatibility.

I do not think this is correct, actually. See https://www.drupal.org/node/3136304.

It's not about the order... it's about comparing array values being string to MarkupInterface objects or viceversa. Unfortunately the method is still undocumented upstream.

https://github.com/sebastianbergmann/phpunit-documentation-english/issue...
https://github.com/sebastianbergmann/phpunit/issues/3511

catch’s picture

mondrake’s picture

I was wrong in #18; the relevant comments are #25 #26 #27

alexpott’s picture

Issue tags: +9.1.0 release notes
catch’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

effulgentsia’s picture

I'm not clear from reading this issue why we had to keep using PHPUnit 8 on PHP 7.3, but whatever the reason was, I wonder if it's been addressed since then in later releases of PHPUnit 9, so I opened #3217451: [TESTING ONLY; DO NOT COMMIT] Update to PHPUnit 9.