1--TEST--
2compareDocumentPosition: attribute order for different element
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = new DOMDocument();
9$dom->loadXML(<<<XML
10<?xml version="1.0"?>
11<outer>
12    <inner a="b" c="d" e="f" />
13    <inner a="b" x="y" />
14</outer>
15XML);
16
17$attrs1 = $dom->documentElement->firstElementChild->attributes;
18$attrs2 = $dom->documentElement->firstElementChild->nextElementSibling->attributes;
19
20foreach ($attrs1 as $attr1) {
21    foreach ($attrs2 as $attr2) {
22        echo "--- Compare 1->2 {$attr1->name} and {$attr2->name} ---\n";
23        var_dump($attr1->compareDocumentPosition($attr2) === DOMNode::DOCUMENT_POSITION_FOLLOWING);
24        echo "--- Compare 2->1 {$attr1->name} and {$attr2->name} ---\n";
25        var_dump($attr2->compareDocumentPosition($attr1) === DOMNode::DOCUMENT_POSITION_PRECEDING);
26    }
27}
28
29?>
30--EXPECT--
31--- Compare 1->2 a and a ---
32bool(true)
33--- Compare 2->1 a and a ---
34bool(true)
35--- Compare 1->2 a and x ---
36bool(true)
37--- Compare 2->1 a and x ---
38bool(true)
39--- Compare 1->2 c and a ---
40bool(true)
41--- Compare 2->1 c and a ---
42bool(true)
43--- Compare 1->2 c and x ---
44bool(true)
45--- Compare 2->1 c and x ---
46bool(true)
47--- Compare 1->2 e and a ---
48bool(true)
49--- Compare 2->1 e and a ---
50bool(true)
51--- Compare 1->2 e and x ---
52bool(true)
53--- Compare 2->1 e and x ---
54bool(true)
55