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.

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.36 KB

Patch

jonathan1055’s picture

Status: Needs review » Needs work
Parent issue: » #3136831: [meta] Drupal9 Readiness and compatibility - Scheduler

All 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.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new5.67 KB

Patch to add a new Trait with the missing assertions (for 8.7) but do nothing if the assertions already exist.

jonathan1055’s picture

StatusFileSize
new5.07 KB

That worked but was a bit clumsy, adding the new EmptyTrait file. Here is a better version.

  • jonathan1055 committed 54b1600 on 8.x-1.x
    Issue #3136744 by jonathan1055: Replace assertContains() with...
jonathan1055’s picture

Title: Replace assertContains() with assertStringContainsString() » Replace assertContains() with assertStringContainsString() and add trait for core 8.7
Status: Needs review » Fixed

Thanks 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.

Status: Fixed » Closed (fixed)

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