Skip to content

Commit 9644b93

Browse files
committed
Add a regression test for bug #69168
This additionally tests for modifications of nodes. Co-authored-by: juha.ikavalko@agentit.fi
1 parent a2deee2 commit 9644b93

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

ext/xsl/tests/bug69168.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
bug #69168 (DomNode::getNodePath() returns invalid path)
3+
--EXTENSIONS--
4+
xsl
5+
--FILE--
6+
<?php
7+
$xml = <<<EOB
8+
<allusers><user><uid>bob</uid></user><user><uid>joe</uid></user></allusers>
9+
EOB;
10+
$xsl = <<<EOB
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
13+
<xsl:template match="allusers">
14+
<xsl:for-each select="user">
15+
<xsl:value-of select="php:function('getPath',uid)"/><br />
16+
</xsl:for-each>
17+
</xsl:template>
18+
</xsl:stylesheet>
19+
EOB;
20+
21+
function getPath($input){
22+
$input[0]->nodeValue .= 'a';
23+
return $input[0]->getNodePath() . ' = ' . $input[0]->nodeValue;
24+
}
25+
26+
$proc = new XSLTProcessor();
27+
$proc->registerPHPFunctions();
28+
$xslDoc = new DOMDocument();
29+
$xslDoc->loadXML($xsl);
30+
@$proc->importStyleSheet($xslDoc);
31+
$xmlDoc = new DOMDocument();
32+
$xmlDoc->loadXML($xml);
33+
echo @$proc->transformToXML($xmlDoc);
34+
35+
// Tests modification of the nodes
36+
var_dump($xmlDoc->firstChild->firstChild->firstChild->getNodePath());
37+
var_dump($xmlDoc->firstChild->firstChild->firstChild->nodeValue);
38+
?>
39+
--EXPECT--
40+
<?xml version="1.0"?>
41+
/allusers/user[1]/uid = boba<br/>/allusers/user[2]/uid = joea<br/>
42+
string(21) "/allusers/user[1]/uid"
43+
string(4) "boba"

0 commit comments

Comments
 (0)