So let's say I want to compare two DOMDocument objects. They have the same content but order and formatting might be off. For example, first one outputs this XML:
<responses>
<response id="12">
<foo>bar</foo>
<lorem>ipsum</lorem>
<sit>dolor</sit>
</response></responses>
Other one outputs:
<responses>
<response id="12">
<lorem>ipsum</lorem><sit>dolor</sit>
<foo>bar</foo>
</response>
</responses>
As you can see, they contain the same XML structure but some elements might be in different order and formatting is completely random.
If I do:
$this->assertEquals();
The test will of course fail. I don't want to test just XML structure but also contents.
Any ideas?
This seems to have solved the problem:
https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertXmlStringEqualsXmlString
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With