1--TEST--
2Dom\Node::lookupPrefix()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\XMLDocument::createFromString(<<<XML
9<?xml version="1.0"?>
10<!DOCTYPE html>
11<html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="test">
12    <body>
13        <svg:svg xmlns:svg="http://www.w3.org/2000/svg" height="1"/>
14        <p xmlns:y="test">
15            <x/>
16        </p>
17    </body>
18</html>
19XML);
20
21$body = $dom->getElementsByTagName("body")[0];
22$body->setAttribute("xmlns:a", "urn:a");
23
24echo "--- NULL case because invalid node type ---\n";
25
26var_dump($dom->doctype->lookupPrefix(""));
27
28echo "--- NULL case because xmlns attribute not in xmlns namespace ---\n";
29
30var_dump($body->lookupPrefix("urn:a"));
31
32echo "--- svg case ---\n";
33
34$svg = $dom->getElementsByTagNameNS("*", "svg")[0];
35
36var_dump($svg->lookupPrefix(""));
37var_dump($svg->lookupPrefix("http://www.w3.org/2000/svg"));
38var_dump($svg->lookupPrefix("1"));
39
40echo "--- search for \"test\" ---\n";
41
42foreach (['x', 'p', 'html'] as $name) {
43    $x = $dom->getElementsByTagNameNS("*", $name)[0];
44    var_dump($x->lookupPrefix(""));
45    var_dump($x->lookupPrefix("test"));
46}
47
48?>
49--EXPECT--
50--- NULL case because invalid node type ---
51NULL
52--- NULL case because xmlns attribute not in xmlns namespace ---
53NULL
54--- svg case ---
55NULL
56string(3) "svg"
57NULL
58--- search for "test" ---
59NULL
60string(1) "y"
61NULL
62string(1) "y"
63NULL
64string(1) "x"
65