If you come across this, know that I spent hours trying to figure out what the problem was, and I am putting it out there to help others. It’s going to be short, and most likely uninteresting.
I was working on a small app, my tests were running well, except when I used assertEqualsI so I decided to use assertIdentical as an alternative for those tests that required Equal, basically, Equal is == while identical is === so, they could work interchangeably, just that you have to change the data type to get the desired result, a silly thing to do by the way (just putting it out there).
Anyway, this was the error:
Error: Declaration of PHPUnit_Framework_Comparator_DOMDocument::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) must be compatible with PHPUnit_Framework_Comparator_Object::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false, array &$processed = Array)
I was working with:
CakePHP 2.x
PHP 7.3.5
PHPUnit 3.x Later Updated to PHPUnit 9.01 (While trying to fix the issue)
There are 2 ways to fix this, as I later found out:
Completely re-install PHPUnit and use the latest version: You should not see this error if you are working with the latest version of PHPUnit.
Edit the forbidden file inside the forbidden territory: vendors Folder (Don’t ever do this).
Go into : vendors/phpunit/phpunit/PHPUnit/Framework/Comparator/DOMDocument.php
Locate method: assertEquals(…
Update the parameters with:
array &$processed = array()
So instead of having:
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE)
You have:
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array())
And that’s it.
If by any chance, this was helpful, let me know. :)
Originally posted on medium here