sebastianbergmann/comparator:5.0.2 Introduces (for Drupal) breaking changes

Created on 16 August 2024, about 1 year ago
Updated 8 September 2024, about 1 year ago

Problem/Motivation

phpunit/phpunit released 10.5.30. (https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.30)
Updating to that version causes an update of sebastianbergmann/comparator to 5.0.2. (https://github.com/sebastianbergmann/comparator/releases/tag/5.0.2)

The latter update is where the "fun" starts. The changes in https://github.com/sebastianbergmann/comparator/pull/113/files#diff-40f6... causes the expected and actual arrays to be only sorted if both have only numeric keys in order 0, 1, 2, ... - so called "list mode".

This breaks some of our tests when using assertEqualsCanonicalizing().

Example:

Drupal\Tests\system\Kernel\Common\UrlTest::testLinkBubbleableMetadata
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     'contexts' => Array (
         0 => 'languages:language_interface'
-        1 => 'session'
-        2 => 'theme'
-        3 => 'user.permissions'
+        1 => 'theme'
+        2 => 'user.permissions'
+        6 => 'session'
     )
     'tags' => []
     'max-age' => -1
 )

core/modules/system/tests/src/Kernel/Common/UrlTest.php:71

Previously both arrays would be sorted before comparing, also changing the keys to be in order 0, 1, 2, ..., those days are gone with
sebastianbergmann/comparator going to 5.0.2.

Steps to reproduce

Take a look at the test results of the daily 'Updated deps' run, like this one: failed run.

, there are occurrences of Failed asserting that two arrays are equal.


Also bump the version of phpunit/phpunit which in turn bumps sebastianbergmann/comparator.
This version of PHPUnit has better checks on our tests, that already proved its value in ๐Ÿ“Œ phpunit/phpunit:10.5.30 Introduces (for Drupal) breaking changes Needs work .

Proposed resolution

Fix Failed asserting that two arrays are equal. test failures, by returning the array_values() of the method that causes the test-failure, since we're only interested in the values anyway.

There's a Slack discussion about this with @longwave here: https://drupal.slack.com/archives/C079NQPQUEN/p1723799215004749

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
PHPUnitย  โ†’

Last updated 1 day ago

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands spokje

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024