Skip to content

Commit 5dfcef7

Browse files
committed
- New tests (testfest BerlinUG)
1 parent 424c018 commit 5dfcef7

19 files changed

+493
-0
lines changed

ext/xsl/tests/xsl-phpinfo.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Test phpinfo() displays xsl info
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("xsl")) {
6+
die("SKIP extension gettext not loaded\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
phpinfo();
12+
?>
13+
--EXPECTF--
14+
%a
15+
libxslt compiled against libxml Version%a
16+
--CREDITS--
17+
Christian Weiske, cweiske@php.net
18+
PHP Testfest Berlin 2009-05-09
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Check xsltprocessor::getParameter with undefined parameter
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
var_dump($proc->getParameter('', 'doesnotexist'));
13+
--EXPECTF--
14+
bool(false)
15+
--CREDITS--
16+
Christian Weiske, cweiske@php.net
17+
PHP Testfest Berlin 2009-05-09
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Check xsltprocessor::getparameter error handling
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
var_dump($proc->getParameter());
13+
var_dump($proc->getParameter(array(), array()));
14+
var_dump($proc->getParameter('', array()));
15+
--EXPECTF--
16+
Warning: XSLTProcessor::getParameter() expects exactly 2 parameters, 0 given in %s on line %d
17+
bool(false)
18+
19+
Warning: XSLTProcessor::getParameter() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d
20+
bool(false)
21+
22+
Warning: XSLTProcessor::getParameter() expects parameter 2 to be %binary_string_optional%, array given in %s on line %d
23+
bool(false)
24+
--CREDITS--
25+
Christian Weiske, cweiske@php.net
26+
PHP Testfest Berlin 2009-05-09
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Check xsltprocessor::getparameter functionality
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
$proc->importStylesheet($xsl);
13+
$proc->setParameter('', 'key', 'value');
14+
var_dump($proc->getParameter('', 'key'));
15+
--EXPECTF--
16+
%string|unicode%(5) "value"
17+
--CREDITS--
18+
Christian Weiske, cweiske@php.net
19+
PHP Testfest Berlin 2009-05-09
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
$phpfuncxsl = new domDocument();
13+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
14+
if(!$phpfuncxsl) {
15+
echo "Error while parsing the xsl document\n";
16+
exit;
17+
}
18+
$proc->importStylesheet($phpfuncxsl);
19+
var_dump($proc->registerPHPFunctions());
20+
var_dump($proc->transformToXml($dom));
21+
22+
//var_dump($proc->registerPHPFunctions(array()));
23+
//var_dump($proc->transformToXml($dom));
24+
25+
--EXPECTF--
26+
NULL
27+
string(18) "This Is An Example"
28+
--CREDITS--
29+
Christian Weiske, cweiske@php.net
30+
PHP Testfest Berlin 2009-05-09
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions with array called multiple times
3+
--DESCRIPTION--
4+
When being called multiple times with an array,
5+
registerPHPFunctions adds the new functions to the allowed parameter
6+
list - it does not replace the previously allowed functions.
7+
--SKIPIF--
8+
<?php
9+
if (!extension_loaded('xsl')) {
10+
die("skip\n");
11+
}
12+
?>
13+
--FILE--
14+
<?php
15+
include dirname(__FILE__) .'/prepare.inc';
16+
$phpfuncxsl = new domDocument();
17+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
18+
if(!$phpfuncxsl) {
19+
echo "Error while parsing the xsl document\n";
20+
exit;
21+
}
22+
$proc->importStylesheet($phpfuncxsl);
23+
var_dump($proc->registerPHPFunctions(array('strpos', 'ucwords')));
24+
var_dump($proc->registerPHPFunctions(array('strrev', 'array_key_exists')));
25+
var_dump($proc->registerPHPFunctions(array()));
26+
var_dump($proc->transformToXml($dom));
27+
--EXPECTF--
28+
NULL
29+
NULL
30+
NULL
31+
string(18) "This Is An Example"
32+
--CREDITS--
33+
Christian Weiske, cweiske@php.net
34+
PHP Testfest Berlin 2009-05-09
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions with array and a not allowed function
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
$phpfuncxsl = new domDocument();
13+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
14+
if(!$phpfuncxsl) {
15+
echo "Error while parsing the xsl document\n";
16+
exit;
17+
}
18+
$proc->importStylesheet($phpfuncxsl);
19+
var_dump($proc->registerPHPFunctions(array()));
20+
var_dump($proc->transformToXml($dom));
21+
--EXPECTF--
22+
NULL
23+
24+
Warning: XSLTProcessor::transformToXml(): Not allowed to call handler 'ucwords()' in %s on line %d
25+
NULL
26+
--CREDITS--
27+
Christian Weiske, cweiske@php.net
28+
PHP Testfest Berlin 2009-05-09
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions with array
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
$phpfuncxsl = new domDocument();
13+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
14+
if(!$phpfuncxsl) {
15+
echo "Error while parsing the xsl document\n";
16+
exit;
17+
}
18+
$proc->importStylesheet($phpfuncxsl);
19+
var_dump($proc->registerPHPFunctions(array('ucwords')));
20+
var_dump($proc->transformToXml($dom));
21+
--EXPECTF--
22+
NULL
23+
string(18) "This Is An Example"
24+
--CREDITS--
25+
Christian Weiske, cweiske@php.net
26+
PHP Testfest Berlin 2009-05-09
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions and a non-string function in xsl
3+
--DESCRIPTION--
4+
The XSL script tries to call a php function that is not a string which
5+
is expected to fail
6+
--SKIPIF--
7+
<?php
8+
if (!extension_loaded('xsl')) {
9+
die("skip\n");
10+
}
11+
?>
12+
--FILE--
13+
<?php
14+
include dirname(__FILE__) .'/prepare.inc';
15+
$phpfuncxsl = new domDocument();
16+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc-nostring.xsl");
17+
if(!$phpfuncxsl) {
18+
echo "Error while parsing the xsl document\n";
19+
exit;
20+
}
21+
$proc->importStylesheet($phpfuncxsl);
22+
var_dump($proc->registerPHPFunctions());
23+
var_dump($proc->transformToXml($dom));
24+
--EXPECTF--
25+
NULL
26+
27+
Warning: XSLTProcessor::transformToXml(): Handler name must be a string in %s on line %d
28+
29+
Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: evaluation failed in %s on line %d
30+
31+
Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element value-of in %s on line %d
32+
33+
Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %s on line %d
34+
NULL
35+
--CREDITS--
36+
Christian Weiske, cweiske@php.net
37+
PHP Testfest Berlin 2009-05-09
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions and a undefined php function
3+
--DESCRIPTION--
4+
The XSL script tries to call a php function that is not defined
5+
--SKIPIF--
6+
<?php
7+
if (!extension_loaded('xsl')) {
8+
die("skip\n");
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
include dirname(__FILE__) .'/prepare.inc';
14+
$phpfuncxsl = new domDocument();
15+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc-undef.xsl");
16+
if(!$phpfuncxsl) {
17+
echo "Error while parsing the xsl document\n";
18+
exit;
19+
}
20+
$proc->importStylesheet($phpfuncxsl);
21+
var_dump($proc->registerPHPFunctions());
22+
var_dump($proc->transformToXml($dom));
23+
--EXPECTF--
24+
NULL
25+
26+
Warning: XSLTProcessor::transformToXml(): Unable to call handler undefinedfunc() in %s on line %d
27+
28+
Warning: XSLTProcessor::transformToXml(): xmlXPathCompiledEval: evaluation failed in %s on line %d
29+
30+
Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element value-of in %s on line %d
31+
32+
Warning: XSLTProcessor::transformToXml(): XPath evaluation returned no result. in %s on line %d
33+
NULL
34+
--CREDITS--
35+
Christian Weiske, cweiske@php.net
36+
PHP Testfest Berlin 2009-05-09
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions called with null to reset
3+
--DESCRIPTION--
4+
When being called multiple times with an array,
5+
registerPHPFunctions adds the new functions to the allowed parameter
6+
list - it does not replace the previously allowed functions.
7+
--SKIPIF--
8+
<?php
9+
if (!extension_loaded('xsl')) {
10+
die("skip\n");
11+
}
12+
?>
13+
--FILE--
14+
<?php
15+
include dirname(__FILE__) .'/prepare.inc';
16+
$phpfuncxsl = new domDocument();
17+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
18+
if(!$phpfuncxsl) {
19+
echo "Error while parsing the xsl document\n";
20+
exit;
21+
}
22+
$proc->importStylesheet($phpfuncxsl);
23+
var_dump($proc->registerPHPFunctions('ucwords'));
24+
var_dump($proc->registerPHPFunctions(null));
25+
var_dump($proc->transformToXml($dom));
26+
--EXPECTF--
27+
NULL
28+
NULL
29+
string(18) "This Is An Example"
30+
--CREDITS--
31+
Christian Weiske, cweiske@php.net
32+
PHP Testfest Berlin 2009-05-09
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions with string called multiple times
3+
--DESCRIPTION--
4+
When being called multiple times with a stringular function name only,
5+
registerPHPFunctions adds the new function to the allowed parameter
6+
list - it does not replace the old function.
7+
--SKIPIF--
8+
<?php
9+
if (!extension_loaded('xsl')) {
10+
die("skip\n");
11+
}
12+
?>
13+
--FILE--
14+
<?php
15+
include dirname(__FILE__) .'/prepare.inc';
16+
$phpfuncxsl = new domDocument();
17+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
18+
if(!$phpfuncxsl) {
19+
echo "Error while parsing the xsl document\n";
20+
exit;
21+
}
22+
$proc->importStylesheet($phpfuncxsl);
23+
var_dump($proc->registerPHPFunctions('ucwords'));
24+
var_dump($proc->registerPHPFunctions('strpos'));
25+
var_dump($proc->transformToXml($dom));
26+
--EXPECTF--
27+
NULL
28+
NULL
29+
string(18) "This Is An Example"
30+
--CREDITS--
31+
Christian Weiske, cweiske@php.net
32+
PHP Testfest Berlin 2009-05-09
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Check xsltprocessor::registerPHPFunctions with string and not allowed function
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) {
6+
die("skip\n");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
include dirname(__FILE__) .'/prepare.inc';
12+
$phpfuncxsl = new domDocument();
13+
$phpfuncxsl->load(dirname(__FILE__)."/phpfunc.xsl");
14+
if(!$phpfuncxsl) {
15+
echo "Error while parsing the xsl document\n";
16+
exit;
17+
}
18+
$proc->importStylesheet($phpfuncxsl);
19+
var_dump($proc->registerPHPFunctions('strpos'));
20+
var_dump($proc->transformToXml($dom));
21+
--EXPECTF--
22+
NULL
23+
24+
Warning: XSLTProcessor::transformToXml(): Not allowed to call handler 'ucwords()' in %s on line %d
25+
NULL
26+
--CREDITS--
27+
Christian Weiske, cweiske@php.net
28+
PHP Testfest Berlin 2009-05-09

0 commit comments

Comments
 (0)