diff options
author | Felipe Pena <felipe@php.net> | 2009-05-23 14:44:37 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2009-05-23 14:44:37 +0000 |
commit | d2616018e49e666fd376ac9ca7e840174ee241f7 (patch) | |
tree | 7a8e67004e5858db653ba5dd036c90aa39590ac6 | |
parent | 558e061d1fc136063b9cd51f31bef7e5abd4bf88 (diff) | |
download | php-git-d2616018e49e666fd376ac9ca7e840174ee241f7.tar.gz |
- New tests (testfest BerlinUG)
19 files changed, 493 insertions, 0 deletions
diff --git a/ext/xsl/tests/xsl-phpinfo.phpt b/ext/xsl/tests/xsl-phpinfo.phpt new file mode 100644 index 0000000000..83e6729ce6 --- /dev/null +++ b/ext/xsl/tests/xsl-phpinfo.phpt @@ -0,0 +1,18 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_getParameter-invalidparam.phpt b/ext/xsl/tests/xsltprocessor_getParameter-invalidparam.phpt new file mode 100644 index 0000000000..19f7791032 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_getParameter-invalidparam.phpt @@ -0,0 +1,17 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_getParameter-wrongparam.phpt b/ext/xsl/tests/xsltprocessor_getParameter-wrongparam.phpt new file mode 100644 index 0000000000..758d4bab21 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_getParameter-wrongparam.phpt @@ -0,0 +1,26 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_getParameter.phpt b/ext/xsl/tests/xsltprocessor_getParameter.phpt new file mode 100644 index 0000000000..2430bc88a4 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_getParameter.phpt @@ -0,0 +1,19 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-allfuncs.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-allfuncs.phpt new file mode 100644 index 0000000000..1f0453ec84 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-allfuncs.phpt @@ -0,0 +1,30 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array-multiple.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array-multiple.phpt new file mode 100644 index 0000000000..a5f23735c9 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array-multiple.phpt @@ -0,0 +1,34 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array-notallowed.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array-notallowed.phpt new file mode 100644 index 0000000000..9492fc6861 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array-notallowed.phpt @@ -0,0 +1,28 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array.phpt new file mode 100644 index 0000000000..0e467aabaa --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array.phpt @@ -0,0 +1,26 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt new file mode 100644 index 0000000000..a0d6bf6b75 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcnostring.phpt @@ -0,0 +1,37 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt new file mode 100644 index 0000000000..1aa7bb051d --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-funcundef.phpt @@ -0,0 +1,36 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-null.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-null.phpt new file mode 100644 index 0000000000..f74d785042 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-null.phpt @@ -0,0 +1,32 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string-multiple.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string-multiple.phpt new file mode 100644 index 0000000000..f15c08d327 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string-multiple.phpt @@ -0,0 +1,32 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string-notallowed.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string-notallowed.phpt new file mode 100644 index 0000000000..9257749714 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string-notallowed.phpt @@ -0,0 +1,28 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string.phpt b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string.phpt new file mode 100644 index 0000000000..5fbba909b1 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-string.phpt @@ -0,0 +1,26 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_removeParameter-invalidparam.phpt b/ext/xsl/tests/xsltprocessor_removeParameter-invalidparam.phpt new file mode 100644 index 0000000000..f35b470840 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_removeParameter-invalidparam.phpt @@ -0,0 +1,18 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_removeParameter-wrongparams.phpt b/ext/xsl/tests/xsltprocessor_removeParameter-wrongparams.phpt new file mode 100644 index 0000000000..c2b4f4c0c3 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_removeParameter-wrongparams.phpt @@ -0,0 +1,23 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_removeParameter.phpt b/ext/xsl/tests/xsltprocessor_removeParameter.phpt new file mode 100644 index 0000000000..92be056985 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_removeParameter.phpt @@ -0,0 +1,20 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_setparameter-errorquote.phpt b/ext/xsl/tests/xsltprocessor_setparameter-errorquote.phpt new file mode 100644 index 0000000000..44e49de601 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_setparameter-errorquote.phpt @@ -0,0 +1,21 @@ +--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 diff --git a/ext/xsl/tests/xsltprocessor_setparameter-nostring.phpt b/ext/xsl/tests/xsltprocessor_setparameter-nostring.phpt new file mode 100644 index 0000000000..c4fcd709ea --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_setparameter-nostring.phpt @@ -0,0 +1,22 @@ +--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 |