+++ /dev/null
---TEST--
-Check for xslt presence
---SKIPIF--
-<?php if (!extension_loaded("xslt")) print "skip"; ?>
---POST--
---GET--
---FILE--
-<?php
-echo "xslt extension is available";
-?>
---EXPECT--
-xslt extension is available
\ No newline at end of file
+++ /dev/null
---TEST--
-Pass long string to 'file' argument, bug #17791
---SKIPIF--
-<?php include("skipif.inc"); ?>
---FILE--
-<?php
-$xmlstring = str_repeat('x', 512);
-$xslstring = 'x';
-$xh = xslt_create();
-$result = @xslt_process($xh, $xmlstring, $xslstring);
-@xslt_free($xh);
-echo("OK");
-?>
---EXPECT--
-OK
+++ /dev/null
---TEST--
-Pass object for xslt_error_handler, bug #17931
---SKIPIF--
-<?php include("skipif.inc"); ?>
---FILE--
-<?php
-class xsl {
-
- function xsl() {
- $this->_parser = xslt_create();
- }
-
- function set_error() {
- xslt_set_error_handler($this->_parser, array($this, 'xslt_trap_error'));
- echo "OK";
- }
-
- function xslt_trap_error($parser, $errorno, $level, $fields) {
- return TRUE;
- }
- function clean() {
- xslt_free($this->_parser);
- }
-}
-
-$x = new xsl;
-// work-around for possible '$this does not exist' bug in constructor
-$x->set_error();
-$x->clean();
-?>
---EXPECT--
-OK
+++ /dev/null
---TEST--
-Set a non-existing scheme handler
---SKIPIF--
-<?php include("skipif.inc"); ?>
---FILE--
-<?php
-function bar()
-{
- return 1;
-}
-$xh = xslt_create();
-$xmlstring = '<foo><barred /></foo>';
-$xslstring = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/1999/XSL/Transform"><xsl:for-each select="/"><xsl:value-of select="document(\'bogus://foo\')" /></xsl:for-each></xsl:stylesheet>';
-xslt_set_scheme_handlers($xh, array('get_all' => 'foo'));
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring));
-xslt_free($xh);
-echo("OK");
-?>
---EXPECT--
-OK
+++ /dev/null
---TEST--
-Various ways to provide xml and xslt arguments and params
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('utf8_encode')) {
- die("skip\n");
-}
-?>
---FILE--
-<?php
-error_reporting(E_ALL);
-$xmlfile = 'ext/xslt/tests/test.xml';
-$xslfile = 'ext/xslt/tests/args.xsl';
-$xmldata = @implode('', @file($xmlfile));
-$xslsheet = @implode('', @file($xslfile));
-
-$xh = xslt_create();
-$result = xslt_process($xh, $xmlfile, $xslfile);
-print "$result\n";
-$result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata));
-print "$result\n";
-$result = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslsheet));
-print "$result\n";
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet));
-print "$result\n";
-
-// The same, with params
-$xslfile = 'ext/xslt/tests/param.xsl';
-$xslsheet = implode('', file($xslfile));
-$params = array("Test has passed", "PHP QA®");
-
-foreach($params AS $val)
-{
- $val = utf8_encode($val);
- $result = xslt_process($xh, $xmlfile, $xslfile, NULL, NULL, array('insertion' => $val));
- print "$result\n";
- $result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata), array('insertion' => $val));
- print "$result\n";
- $result = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslsheet), array('insertion' => $val));
- print "$result\n";
- $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet), array('insertion' => $val));
- print "$result\n";
-}
-
-xslt_free($xh);
-?>
---EXPECT--
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-PHP QA®
-PHP QA®
-PHP QA®
-PHP QA®
+++ /dev/null
---TEST--
-Crash xslt_process with reused handler (this test may take a while)
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('utf8_encode')) {
- die("skip\n");
-}
-?>
---FILE--
-<?php
-error_reporting(E_ALL);
-$xmlfile = 'ext/xslt/tests/test.xml';
-$xslfile = 'ext/xslt/tests/param.xsl';
-$xmldata = @implode('', @file($xmlfile));
-$xslsheet = @implode('', @file($xslfile));
-
-/*
- * Tested on a Cyrix 200MMX/128MB took 2 secs. Should be a reasonable margin.
- *
- * It's not meant as an actual speed test, but if it's slower than this,
- * there must be something significantly off in the php/sablot/expat trio.
- * Emulation OS's come to mind...
- */
-$want_time = 6;
-
-function make_param()
-{
- $ret_val = '';
- $numchars = mt_rand(2,16);
- $illegal = array(0,256,512);
- for($i=0;$i<$numchars;$i++)
- {
- $char=0;
- while(in_array($char, $illegal))
- {
- $char .= mt_rand(32, 512);
- }
- $ret_val .= chr($char);
- }
-
- return utf8_encode($ret_val);
-}
-
-function decode($string)
-{
- $ret_val = '';
- for($i=0; $i<strlen($string);$i++)
- {
- $ret_val .= ord(substr($string,$i,1)) . " ";
- }
- return $ret_val;
-}
-
-
-$xh = xslt_create();
-
-$t1 = time();
-for ($i=0; $i<50; $i++)
-{
- $val = make_param();
- $result = xslt_process($xh, $xmlfile, $xslfile, NULL, NULL, array('insertion' => $val));
- if(!$result or $result != utf8_decode($val))
- print "Failed $i / ".utf8_decode($val).": $result\n\tDecode: " . decode(utf8_decode($val)) . "\n" ;
-}
-print "OK\n";
-xslt_free($xh);
-$t2 = time();
-$op_time = $t2 - $t1;
-if($op_time > $want_time)
- print "This test took more than $want_time seconds. Either you have a very slow / busy machine, or there's something very wrong with the speed. Your time: $op_time";
-?>
---EXPECT--
-OK
+++ /dev/null
---TEST--
-xslt_set_opt function and public entities
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('xslt_setopt')) {
- die("skip\n");
-}
-?>
---FILE--
-<?php
-error_reporting(E_ALL);
-$xmlfile = 'ext/xslt/tests/public.xml';
-$xslfile = 'ext/xslt/tests/args.xsl';
-
-$xh = xslt_create();
-// Tell Sablotron to process public entities
-xslt_setopt($xh, XSLT_SAB_PARSE_PUBLIC_ENTITIES);
-
-$result = xslt_process($xh, $xmlfile, $xslfile);
-print "$result\n";
-
-$xslstring = implode('', file($xslfile));
-$xslstring = str_replace('method="text"', 'method="html"', $xslstring);
-$xslstring = str_replace('<xsl:value-of select="." />', '<html><head><title>foo</title></head><body><p><xsl:value-of select="." /></p></body></html>', $xslstring);
-// DEBUG: print $xslstring;
-
-xslt_setopt($xh, XSLT_SAB_PARSE_PUBLIC_ENTITIES | XSLT_SAB_DISABLE_ADDING_META);
-$result_nometa = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring));
-// DEBUG: print "$result_nometa\n";
-
-xslt_setopt($xh, XSLT_SAB_PARSE_PUBLIC_ENTITIES);
-$result_meta = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring));
-// DEBUG: print "$result_meta\n";
-
-/* Also test if they're equal. That would mean, that disable-adding-meta is set to off
- at compile time and our call to xslt_setopt failed to reset that */
-if($result_meta != $result_nometa && FALSE === stristr($result_nometa, '<meta http-equiv="Content-Type"'))
-{
- print "OK\n";
-}
-
-xslt_free($xh);
-?>
---EXPECT--
-PHP QA®
-OK
+++ /dev/null
---TEST--
-xslt_set_object function
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('xslt_set_object')) {
- die("skip\n");
-}
-?>
---FILE--
-<?php
-error_reporting(E_ALL);
-class XSLTTester
-{
- var $_success = false;
- var $_success2 = false;
-
- function XSLTTester()
- {}
-
- // this function will register this object as the
- // callback object.
- function test1($xmlfile,$xslfile)
- {
- $xh = xslt_create();
- xslt_set_object($xh,$this);
- $handlers = array('get_all'=> 'handle_getall');
- xslt_set_scheme_handlers($xh,$handlers);
- $res = xslt_process($xh,$xmlfile,$xslfile);
- xslt_free($xh);
- return 1;
- }
-
- // this function will pass this object as in set_scheme_handler
- function test2($xmlfile,$xslfile)
- {
- $xh = xslt_create();
- $handlers = array('get_all'=> array(&$this,'handle_getall2'));
- xslt_set_scheme_handlers($xh,$handlers);
- $res = xslt_process($xh,$xmlfile,$xslfile);
- xslt_free($xh);
- return 1;
- }
- function handle_getall($xh,$scheme,$rest)
- {
- $this->_success = true;
- $rest = substr($rest,2);
- return implode('', file('ext/xslt/tests/'.$rest));
- }
- function handle_getall2($xh,$scheme,$rest)
- {
- $this->_success2 = true;
- $rest = substr($rest,2);
- return implode('', file('ext/xslt/tests/'.$rest));
- }
- function testSucceeded()
- {
- return $this->_success;
- }
- function test2Succeeded()
- {
- return $this->_success2;
- }
-}
-
-$xmlfile = 'ext/xslt/tests/test.xml';
-$xslfile = 'ext/xslt/tests/xslt_set_object.xsl';
-
-$testobj = new XSLTTester();
-$testobj->test1($xmlfile,$xslfile);
-
-$testobj->test2($xmlfile,$xslfile);
-
-if ($testobj->testSucceeded())
- print "OK\n";
-else
- print "FAILED\n";
-
-if ($testobj->test2Succeeded())
- print "OK\n";
-else
- print "FAILED\n";
-
-?>
---EXPECT--
-OK
-OK
+++ /dev/null
---TEST--
-Memoryleak in error printing
---SKIPIF--
-<?php include("skipif.inc"); ?>
---INI--
-error_reporting=2047
-display_errors=0
-track_errors=1
---FILE--
-<?php
-$xmlfile = 'ext/xslt/tests/non-existent.xml';
-$xslfile = 'ext/xslt/tests/non-existent.xsl';
-
-$xh = xslt_create();
-$result = xslt_process($xh, $xmlfile, $xslfile, NULL);
-xslt_free($xh);
-
-echo $php_errormsg."\n";
-?>
---EXPECTF--
-Sablotron error on line none: cannot open file '%s/ext/xslt/tests/non-existent.xsl'