Problem/Motivation

This is blocker to run a lot of tests without deprecation warnings

Steps to reproduce

https://3v4l.org/0rAA5

$v=NULL;var_dump(strpos($v, 's'));

Run \Drupal\Tests\contact\Kernel\MessageEntityTest

vendor/bin/phpunit -c core/phpunit.xml.dist --colors=always --debug -v \
core/modules/contact/tests/src/Kernel/MessageEntityTest.php
PHPUnit 8.5.21 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3
Configuration: /var/www/html/web/core/phpunit.xml.dist

Testing Drupal\Tests\contact\Kernel\MessageEntityTest
Test 'Drupal\Tests\contact\Kernel\MessageEntityTest::testMessageMethods' started
Test 'Drupal\Tests\contact\Kernel\MessageEntityTest::testMessageMethods' ended


Time: 1.73 seconds, Memory: 6.00 MB

OK (1 test, 25 assertions)

Unsilenced deprecation notices (1)

  1x: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
    1x in MessageEntityTest::testMessageMethods from Drupal\Tests\contact\Kernel

Proposed resolution

Use empty string instead of NULL for $namespace and $autoload

Remaining tasks

review/commit

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3240191-2.patch955 bytesandypost
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
955 bytes
andypost’s picture

Issue summary: View changes

added example code to catch

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

This is the same fix on the meta that makes lots of deprecations go away.

  • catch committed 2b279d3 on 9.3.x
    Issue #3240191 by andypost, alexpott: \Drupal\KernelTests\KernelTestBase...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 2b279d3 and pushed to 9.3.x. Thanks!

Status: Fixed » Closed (fixed)

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