Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Implement \Dxw\Assertions\XML #4

@mallorydxw

Description

@mallorydxw

API should be identical to \Dxw\Assertions\HTML.

Ideally we should convert both documents to Canonical XML.

Here's a bit of code we used on another project:

    protected function assertXMLEquals($expected, $actual)
    {
        call_user_func_array(
            [$this, 'assertEquals'],
            array_map(
                function ($x) {
                    $d = new DOMDocument;
                    $d->loadXML($x);

                    $t = $d->C14N();
                    $t = preg_replace('/^\s+/m', '', $t);
                    $t = preg_replace('/\n/', '', $t);
                    $t = preg_replace('/></', ">\n<", $t);
                    return $t;
                },
                [$expected, $actual]
            )
        );
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions