Skip to content

Commit c4805ff

Browse files
author
Melvyn Sopacua
committed
Improve testkit for xslt.
002.phpt and 003.phpt are regression tests for reported bugs. 004.phpt has been known to cause problems in some Sab/PHP combinations. No known reports in bug db for that one. Added skip mechanism @- Added regression test for bugs php#17791 and php#17931 (Melvyn)
1 parent 7f1ad23 commit c4805ff

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

ext/xslt/tests/002.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Pass long string to 'file' argument, bug #17791
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
$xmlstring = str_repeat('x', 512);
8+
$xslstring = 'x';
9+
$xh = xslt_create();
10+
$result = @xslt_process($xh, $xmlstring, $xslstring);
11+
@xslt_free($xh);
12+
echo("OK");
13+
?>
14+
--EXPECT--
15+
OK

ext/xslt/tests/003.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Pass object for xslt_error_handler, bug #17931
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
include('xslt_set_error_handler.php');
8+
?>
9+
--EXPECT--
10+
OK

ext/xslt/tests/skipif.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
if(!extension_loaded("xslt") && ini_get("enable_dl")) {
3+
$dlext = (substr(PHP_OS, 0, 4) == "WIN") ? ".dll" : ".so";
4+
@dl("xlst$dlext");
5+
}
6+
if(!extension_loaded("xslt")) {
7+
die("skip\n");
8+
}
9+
?>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
class xsl {
3+
4+
function xsl() {
5+
$this->_parser = xslt_create();
6+
}
7+
8+
function set_error() {
9+
xslt_set_error_handler($this->_parser, array($this, 'xslt_trap_error'));
10+
echo "OK";
11+
}
12+
13+
function xslt_trap_error($parser, $errorno, $level, $fields) {
14+
return TRUE;
15+
}
16+
function clean() {
17+
xslt_free($this->_parser);
18+
}
19+
}
20+
21+
$x = new xsl;
22+
// work-around for possible '$this does not exist' bug in constructor
23+
$x->set_error();
24+
$x->clean();
25+
?>

0 commit comments

Comments
 (0)