Problem/Motivation

core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php triggers deprecations on PHP 8.1 because a mocked method returns a NULL when a string is expected.

Steps to reproduce

Run core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php on PHP 8.1

Proposed resolution

Fix it.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3241308-2.patch687 bytesalexpott
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
FileSize
687 bytes

Before

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3-dev
Configuration: /Users/alex/dev/sites/drupal8alt.dev/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest
.........................................                         41 / 41 (100%)

Time: 00:00.053, Memory: 12.00 MB

OK (41 tests, 84 assertions)

Remaining self deprecation notices (13)

  13x: substr(): Passing null to parameter #1 ($string) of type string is deprecated
    13x in DefaultTableMappingTest::testGetFieldTableName from Drupal\Tests\Core\Entity\Sql

After

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3-dev
Configuration: /Users/alex/dev/sites/drupal8alt.dev/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\Core\Entity\Sql\DefaultTableMappingTest
.........................................                         41 / 41 (100%)

Time: 00:00.042, Memory: 10.00 MB

OK (41 tests, 84 assertions)
andypost’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php
@@ -362,6 +362,9 @@ public function testGetFieldTableName($table_names, $expected) {
+      ->method('getTargetEntityTypeId')

This method is expected on both interfaces to return string value \Drupal\Core\Field\FieldStorageDefinitionInterface::getTargetEntityTypeId() and \Drupal\Core\Field\FieldDefinitionInterface::getTargetEntityTypeId()

  • larowlan committed 93e9e36 on 9.3.x
    Issue #3241308 by alexpott: core/tests/Drupal/Tests/Core/Entity/Sql/...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 93e9e36 and pushed to 9.3.x. Thanks!

andypost’s picture

Status: Fixed » Closed (fixed)

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