New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertEqualXMLStructure cannot compare nodes with an ID #1879

Closed
leops opened this Issue Sep 28, 2015 · 0 comments

Comments

1 participant
@leops

leops commented Sep 28, 2015

Since assertEqualXMLStructure create a clone of the nodes it's comparing, if those nodes are part of an HTML document and have the id (or name) attribute defined, the test triggers an error with the message ID foo already defined:

<?php
class XmlTest extends \PHPUnit_Framework_TestCase {
    public function testEqualXmlStructure() {
        $actual = new DOMDocument;
        $actual->loadHTML('<html><body><a id="foo"></a></body></html>');

        $expected = new DOMDocument;
        $expected->loadHTML('<html><body><a id="foo"></a></body></html>');

        $this->assertEqualXmlStructure(
            $expected->firstChild->nextSibling,
            $actual->firstChild->nextSibling
        );
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment