Option to add "comparison" to `AssertionFailed`
Closed this issue · 0 comments
kbond commented
When the PHPUnit handler is being used, use PHPUnit's comparison api to generate the standard diff:
Code to create the proper diff:
try {
SebastianBergmann\Comparator::getInstance()
->getComparatorFor($expected, $actual)
->assertEquals($expected, $actual)
;
} catch (SebastianBergmann\Comparator\ComparisonFailure $e) {
$diff = $e->getDiff();
}
Requirements for $expected
/$actual
to be "diffed":
- both arrays
- both strings
- both objects of the same class
Alternative: some kind of phpunit-only hook?