1--TEST--
2registerPhpFunctionNS() function - error cases
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$doc = new DOMDocument();
9$doc->loadHTML('<a href="https://PHP.net">hello</a>');
10
11$xpath = new DOMXPath($doc);
12
13try {
14    $xpath->registerPhpFunctionNS('http://php.net/xpath', 'strtolower', strtolower(...));
15} catch (ValueError $e) {
16    echo $e->getMessage(), "\n";
17}
18
19try {
20    $xpath->registerPhpFunctionNS('urn:foo', 'x:a', strtolower(...));
21} catch (ValueError $e) {
22    echo $e->getMessage(), "\n";
23}
24
25try {
26    $xpath->registerPhpFunctionNS("urn:foo", "\0", strtolower(...));
27} catch (ValueError $e) {
28    echo $e->getMessage(), "\n";
29}
30
31try {
32    $xpath->registerPhpFunctionNS("\0", 'strtolower', strtolower(...));
33} catch (ValueError $e) {
34    echo $e->getMessage(), "\n";
35}
36
37?>
38--EXPECT--
39DOMXPath::registerPhpFunctionNS(): Argument #1 ($namespaceURI) must not be "http://php.net/xpath" because it is reserved by PHP
40DOMXPath::registerPhpFunctionNS(): Argument #2 ($name) must be a valid callback name
41DOMXPath::registerPhpFunctionNS(): Argument #2 ($name) must not contain any null bytes
42DOMXPath::registerPhpFunctionNS(): Argument #1 ($namespaceURI) must not contain any null bytes
43