Tests with D9 on drupal.org use PHPUnit 8 and we get the following deprecations:
Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead.
The optional $ignoreCase parameter of assertContains() is deprecated and will be removed in PHPUnit 9.
Using assertNotContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringNotContainsString() or assertStringNotContainsStringIgnoringCase() instead.
The optional $ignoreCase parameter of assertNotContains() is deprecated and will be removed in PHPUnit 9.
The tests to fix are SchedulerDrushTest::testDrushCronMessages and SchedulerDrushTest::testDrushCronPublishing
Testing at 8.x is not affected because that uses PHPUnit 7.5.20 whereas Drupal 9 uses PHPUnit 8.5.2.
Following recent commits at core 8.9 and 8.8 on #3126797: [D8 only] Add forwards-compatibility shim for assertString(Not)ContainsString()replacements in phpunit 6&7 we now have new forwards-compatibility functions available in PHPUnit 6, which is what drupal.org uses, and early versions of PHPunit 7. These were already included in PHPUnit 7.5.20
assertStringContainsString() and assertStringNotContainsString(). There are also ...IgnoringCase() versions of both functions.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3136744-5.replace-assertContains.patch | 5.07 KB | jonathan1055 |
Comments
Comment #2
jonathan1055 commentedPatch
Comment #3
jonathan1055 commentedAll green tests at Drupal 9! and 8.9 and 8.8.
But as expected we have failures at 8.7 because the forwards-compatibility functions have not been ported back to 8.7.
Comment #4
jonathan1055 commentedPatch to add a new Trait with the missing assertions (for 8.7) but do nothing if the assertions already exist.
Comment #5
jonathan1055 commentedThat worked but was a bit clumsy, adding the new EmptyTrait file. Here is a better version.
Comment #7
jonathan1055 commentedThanks to @longwave and @mondrake on #3126797: [D8 only] Add forwards-compatibility shim for assertString(Not)ContainsString()replacements in phpunit 6&7 for the trait hint, even though I did it a bit differently in the end.
Comment #9
jonathan1055 commentedChanged parent.