--- /dev/null
+--TEST--
+Test phpinfo() displays xsl info
+--SKIPIF--
+<?php
+ if (!extension_loaded("xsl")) {
+ die("SKIP extension gettext not loaded\n");
+ }
+?>
+--FILE--
+<?php
+phpinfo();
+?>
+--EXPECTF--
+%a
+libxslt compiled against libxml Version%a
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::getParameter with undefined parameter
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+var_dump($proc->getParameter('', 'doesnotexist'));
+--EXPECTF--
+bool(false)
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::getparameter error handling
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+var_dump($proc->getParameter());
+var_dump($proc->getParameter(array(), array()));
+var_dump($proc->getParameter('', array()));
+--EXPECTF--
+Warning: XSLTProcessor::getParameter() expects exactly 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: XSLTProcessor::getParameter() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d
+bool(false)
+
+Warning: XSLTProcessor::getParameter() expects parameter 2 to be %binary_string_optional%, array given in %s on line %d
+bool(false)
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::getparameter functionality
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$proc->importStylesheet($xsl);
+$proc->setParameter('', 'key', 'value');
+var_dump($proc->getParameter('', 'key'));
+--EXPECTF--
+%string|unicode%(5) "value"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions());
+var_dump($proc->transformToXml($dom));
+
+//var_dump($proc->registerPHPFunctions(array()));
+//var_dump($proc->transformToXml($dom));
+
+--EXPECTF--
+NULL
+string(18) "This Is An Example"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions with array called multiple times
+--DESCRIPTION--
+When being called multiple times with an array,
+registerPHPFunctions adds the new functions to the allowed parameter
+list - it does not replace the previously allowed functions.
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions(array('strpos', 'ucwords')));
+var_dump($proc->registerPHPFunctions(array('strrev', 'array_key_exists')));
+var_dump($proc->registerPHPFunctions(array()));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+NULL
+NULL
+string(18) "This Is An Example"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions with array and a not allowed function
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions(array()));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+
+Warning: XSLTProcessor::transformToXml(): Not allowed to call handler 'ucwords()' in %s on line %d
+NULL
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions with array
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions(array('ucwords')));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+string(18) "This Is An Example"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions and a non-string function in xsl
+--DESCRIPTION--
+The XSL script tries to call a php function that is not a string which
+is expected to fail
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc-nostring.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions());
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+
+Warning: XSLTProcessor::transformToXml(): Handler name must be a string in %s on line %d
+
+Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: evaluation failed in %s on line %d
+
+Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element value-of in %s on line %d
+
+Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %s on line %d
+NULL
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions and a undefined php function
+--DESCRIPTION--
+The XSL script tries to call a php function that is not defined
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc-undef.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions());
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+
+Warning: XSLTProcessor::transformToXml(): Unable to call handler undefinedfunc() in %s on line %d
+
+Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: evaluation failed in %s on line %d
+
+Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element value-of in %s on line %d
+
+Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %s on line %d
+NULL
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions called with null to reset
+--DESCRIPTION--
+When being called multiple times with an array,
+registerPHPFunctions adds the new functions to the allowed parameter
+list - it does not replace the previously allowed functions.
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions('ucwords'));
+var_dump($proc->registerPHPFunctions(null));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+NULL
+string(18) "This Is An Example"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions with string called multiple times
+--DESCRIPTION--
+When being called multiple times with a stringular function name only,
+registerPHPFunctions adds the new function to the allowed parameter
+list - it does not replace the old function.
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions('ucwords'));
+var_dump($proc->registerPHPFunctions('strpos'));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+NULL
+string(18) "This Is An Example"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions with string and not allowed function
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions('strpos'));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+
+Warning: XSLTProcessor::transformToXml(): Not allowed to call handler 'ucwords()' in %s on line %d
+NULL
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::registerPHPFunctions with string
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$phpfuncxsl = new domDocument();
+$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
+if(!$phpfuncxsl) {
+ echo "Error while parsing the xsl document\n";
+ exit;
+}
+$proc->importStylesheet($phpfuncxsl);
+var_dump($proc->registerPHPFunctions('ucwords'));
+var_dump($proc->transformToXml($dom));
+--EXPECTF--
+NULL
+string(18) "This Is An Example"
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::removeParameter with invalid parameter
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$proc->importStylesheet($xsl);
+var_dump($proc->removeParameter('', 'doesnotexist'));
+--EXPECT--
+bool(false)
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::removeParameter wrong parameter handling
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$proc->removeParameter();
+$proc->removeParameter(array(), array());
+$proc->removeParameter('', array());
+--EXPECTF--
+Warning: XSLTProcessor::removeParameter() expects exactly 2 parameters, 0 given in %s on line %d
+
+Warning: XSLTProcessor::removeParameter() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d
+
+Warning: XSLTProcessor::removeParameter() expects parameter 2 to be %binary_string_optional%, array given in %s on line %d
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::removeParameter functionality
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$proc->importStylesheet($xsl);
+$proc->setParameter('', 'key', 'value');
+$proc->removeParameter('', 'key');
+var_dump($proc->getParameter('', 'key'));
+--EXPECT--
+bool(false)
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::setparameter error handling with both single and double quotes
+--DESCRIPTION--
+Memleak: http://bugs.php.net/bug.php?id=48221
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$proc->importStylesheet($xsl);
+$proc->setParameter('', '', '"\'');
+$proc->transformToXml($dom);
+--EXPECTF--
+Warning: XSLTProcessor::transformToXml(): Cannot create XPath expression (string contains both quote and double-quotes) in %s on line %d
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09
--- /dev/null
+--TEST--
+Check xsltprocessor::setparameter error handling with no-string
+--DESCRIPTION--
+Memleak: http://bugs.php.net/bug.php?id=48221
+--SKIPIF--
+<?php
+ if (!extension_loaded('xsl')) {
+ die("skip\n");
+ }
+?>
+--FILE--
+<?php
+include dirname(__FILE__) .'/prepare.inc';
+$proc->importStylesheet($xsl);
+var_dump($proc->setParameter('', array(4, 'abc')));
+$proc->transformToXml($dom);
+--EXPECTF--
+Warning: XSLTProcessor::setParameter(): Invalid parameter array in %s on line %d
+bool(false)
+--CREDITS--
+Christian Weiske, cweiske@php.net
+PHP Testfest Berlin 2009-05-09