From: Felipe Pena Date: Sat, 23 May 2009 14:52:54 +0000 (+0000) Subject: - New tests (testfest BerlinUG) X-Git-Tag: php-5.2.10RC1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f89db675d7d254f39b5a8280b5f7f378c293c03;p=php - New tests (testfest BerlinUG) --- diff --git a/ext/xsl/tests/phpfunc-nostring.xsl b/ext/xsl/tests/phpfunc-nostring.xsl new file mode 100644 index 0000000000..9ee6a3856c --- /dev/null +++ b/ext/xsl/tests/phpfunc-nostring.xsl @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/ext/xsl/tests/phpfunc-undef.xsl b/ext/xsl/tests/phpfunc-undef.xsl new file mode 100644 index 0000000000..819d0c16d2 --- /dev/null +++ b/ext/xsl/tests/phpfunc-undef.xsl @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/ext/xsl/tests/phpfunc.xsl b/ext/xsl/tests/phpfunc.xsl new file mode 100644 index 0000000000..ba1e734a6e --- /dev/null +++ b/ext/xsl/tests/phpfunc.xsl @@ -0,0 +1,11 @@ + + + + + + + + + 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-- + +--FILE-- + +--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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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..7462ee9b6d --- /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-- + +--FILE-- +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-- +bool(true) +bool(true) +bool(true) +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..996fdd1ae8 --- /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-- + +--FILE-- +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-- +bool(true) + +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..6a7b961a04 --- /dev/null +++ b/ext/xsl/tests/xsltprocessor_registerPHPFunctions-array.phpt @@ -0,0 +1,26 @@ +--TEST-- +Check xsltprocessor::registerPHPFunctions with array +--SKIPIF-- + +--FILE-- +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-- +bool(true) +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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-- + +--FILE-- +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