Skip to content

Conversation

@sebastianbergmann
Copy link
Owner

@sebastianbergmann sebastianbergmann commented Jan 22, 2026

This implements the assertArraysAreIdentical(), assertArraysAreIdenticalIgnoringOrder(), assertArraysHaveIdenticalValues(), assertArraysHaveIdenticalValuesIgnoringOrder(), assertArraysAreEqual(), assertArraysAreEqualIgnoringOrder(), assertArraysHaveEqualValues(), and assertArraysHaveEqualValuesIgnoringOrder() assertions as requested in #6423.

The implementation follows the specification in #6423 (comment).

It is worth noting that the implementation uses the == operator for the new equality-related assertions and does not delegate the comparison to a chain of Comparator objects, as is the case with assertEquals(), for example.

@sebastianbergmann sebastianbergmann added this to the PHPUnit 13.0 milestone Jan 22, 2026
@sebastianbergmann sebastianbergmann self-assigned this Jan 22, 2026
@sebastianbergmann sebastianbergmann added type/enhancement A new idea that should be implemented feature/assertion Issues related to assertions and expectations labels Jan 22, 2026
@sebastianbergmann
Copy link
Owner Author

@Seldaek @theofidry I would greatly appreciate your feedback on this as soon as possible. For the purposes of this review, I suggest focusing on the test cases rather than the implementation.

@staabm Maybe this is of interest to you as well.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.03%. Comparing base (fcbbb46) to head (e2913a6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6477      +/-   ##
============================================
+ Coverage     96.02%   96.03%   +0.01%     
- Complexity     7367     7395      +28     
============================================
  Files           798      801       +3     
  Lines         22664    22753      +89     
============================================
+ Hits          21762    21851      +89     
  Misses          902      902              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastianbergmann sebastianbergmann changed the title Initial work on #6423 New array assertions Jan 22, 2026
Copy link
Contributor

@theofidry theofidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question mark for me looking at the tests is what you expect the behaviour to be for objects with the same structure but of a different class.

I would expect them to be different, but it is not obvious this is what is expected when looking at the tests.

@theofidry
Copy link
Contributor

Looking forward to it 😄

@sebastianbergmann
Copy link
Owner Author

One question mark for me looking at the tests is what you expect the behaviour to be for objects with the same structure but of a different class.

I would expect them to be different, but it is not obvious this is what is expected when looking at the tests.

I would expect that, too. As does PHP:

<?php declare(strict_types=1);
final class A
{
    private string $foo = 'bar';
}

final class B
{
    private string $foo = 'bar';
}

$a = [new A];
$b = [new B];

var_dump($a == $b);
bool(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/assertion Issues related to assertions and expectations type/enhancement A new idea that should be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants