1--TEST--
2Bug #79701 (getElementById does not correctly work with duplicate definitions) - id property variation
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$dom = Dom\XMLDocument::createFromString(<<<XML
8<root>
9    <test1/>
10    <test2/>
11</root>
12XML);
13
14$test1 = $dom->documentElement->firstElementChild;
15$test2 = $test1->nextElementSibling;
16
17echo "--- After parsing ---\n";
18var_dump($dom->getElementById("x")?->nodeName);
19
20echo "--- After setting test2 ---\n";
21$test2->id = "x";
22var_dump($dom->getElementById("x")?->nodeName);
23echo "--- After setting test1 ---\n";
24$test1->id = "x";
25var_dump($dom->getElementById("x")?->nodeName);
26echo "--- After resetting test1 ---\n";
27$test1->id = "y";
28var_dump($dom->getElementById("x")?->nodeName);
29echo "--- After resetting test2 ---\n";
30$test2->id = "y";
31var_dump($dom->getElementById("x")?->nodeName);
32echo "--- After resetting test1 ---\n";
33$test1->id = "x";
34var_dump($dom->getElementById("x")?->nodeName);
35echo "--- After calling setIdAttribute with false on test1 ---\n";
36$test1->setIdAttribute("id", false);
37var_dump($dom->getElementById("x")?->nodeName);
38?>
39--EXPECT--
40--- After parsing ---
41NULL
42--- After setting test2 ---
43string(5) "test2"
44--- After setting test1 ---
45string(5) "test1"
46--- After resetting test1 ---
47string(5) "test2"
48--- After resetting test2 ---
49NULL
50--- After resetting test1 ---
51string(5) "test1"
52--- After calling setIdAttribute with false on test1 ---
53NULL
54