1--TEST-- 2Bug #79701 (getElementById does not correctly work with duplicate definitions) - set attribute ns in html variation 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7function test($namespace) { 8 $dom = Dom\HTMLDocument::createFromString(<<<HTML 9 <p> 10 <em id="x">1</em> 11 <strong id="y">2</strong> 12 </p> 13 HTML, LIBXML_NOERROR); 14 15 $test1 = $dom->getElementById('x'); 16 $test2 = $dom->getElementById('y'); 17 18 echo "--- After resetting em's id ---\n"; 19 20 $test1->setAttributeNS($namespace, "id", 'y'); 21 var_dump($dom->getElementById('x')?->nodeName); 22 var_dump($dom->getElementById('y')?->nodeName); 23 24 echo "--- After resetting strong's id ---\n"; 25 26 $test2->setAttributeNS($namespace, "id", 'x'); 27 var_dump($dom->getElementById('x')?->nodeName); 28 var_dump($dom->getElementById('y')?->nodeName); 29 30 echo "--- After resetting em's id ---\n"; 31 32 $test1->setAttributeNS($namespace, "id", 'z'); 33 var_dump($dom->getElementById('x')?->nodeName); 34 var_dump($dom->getElementById('y')?->nodeName); 35 36 echo "--- After resetting strong's id ---\n"; 37 38 $test2->setAttributeNS($namespace, "id", 'z'); 39 var_dump($dom->getElementById('x')?->nodeName); 40 var_dump($dom->getElementById('y')?->nodeName); 41 42 echo "--- Get id z ---\n"; 43 44 var_dump($dom->getElementById('z')?->nodeName); 45} 46 47echo "=== Test empty namespace ===\n\n"; 48test(""); 49echo "\n=== Test \"urn:x\" namespace ===\n\n"; 50test("urn:x"); 51?> 52--EXPECT-- 53=== Test empty namespace === 54 55--- After resetting em's id --- 56NULL 57string(2) "EM" 58--- After resetting strong's id --- 59string(6) "STRONG" 60string(2) "EM" 61--- After resetting em's id --- 62string(6) "STRONG" 63NULL 64--- After resetting strong's id --- 65NULL 66NULL 67--- Get id z --- 68string(2) "EM" 69 70=== Test "urn:x" namespace === 71 72--- After resetting em's id --- 73string(2) "EM" 74string(6) "STRONG" 75--- After resetting strong's id --- 76string(2) "EM" 77string(6) "STRONG" 78--- After resetting em's id --- 79string(2) "EM" 80string(6) "STRONG" 81--- After resetting strong's id --- 82string(2) "EM" 83string(6) "STRONG" 84--- Get id z --- 85NULL 86