phpunit
phpunit copied to clipboard
Reimplement main aspect of assertEqualXMLStructure
As discussed in https://github.com/sebastianbergmann/phpunit/issues/4091, there is a valid use case for having an assertion ensuring two DOM sub trees are structurally identical.
This PR re-implements the main aspect of the original, deprecated assertEqualXMLStructure: The comparison of two XML trees for structural identicality.
Two DOM trees are to be considered identical when, after canonicalization, the following holds true:
- The same child - parent relationship is maintained
- The same attributes are set on a node
- The attribute values are identical
- The textual content of nodes are identical
Looking at the options of the original, deprecated method, this appears to be stricter. The original method for instance ignored namespace defining attributes as well as textual content.
As I didn't see a use case for that, I did not reimplement that aspect. My implementation basically ignores any whitespace and, due to canonicalization, reorders attributes as needed so the order of attributes is not relevant.
The name assertDOMTreesEqualStructurally is subject to change, only pending a better naming suggestion. It should probably reflect the actual assertion better.
Codecov Report
Merging #4507 into master will decrease coverage by
0.09%. The diff coverage is0.00%.
@@ Coverage Diff @@
## master #4507 +/- ##
============================================
- Coverage 83.69% 83.59% -0.10%
- Complexity 4663 4664 +1
============================================
Files 293 293
Lines 12030 12044 +14
============================================
Hits 10068 10068
- Misses 1962 1976 +14
| Impacted Files | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| src/Framework/Assert.php | 91.21% <0.00%> (-1.82%) |
231.00 <1.00> (+1.00) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 61180a8...85d4c05. Read the comment docs.
This branch has conflicts that must be resolved.