diff options
author | David Viner <dviner@php.net> | 2002-10-07 16:59:08 +0000 |
---|---|---|
committer | David Viner <dviner@php.net> | 2002-10-07 16:59:08 +0000 |
commit | 0803ebfa3ee8011c03b9ff0462de063505e97b83 (patch) | |
tree | 482506b0bed203fda0d9ef3eeca18491a130107e /ext/xslt | |
parent | 931e25297bfcc819eaa7b48f0ace8d244b3a4ee5 (diff) | |
download | php-git-0803ebfa3ee8011c03b9ff0462de063505e97b83.tar.gz |
adding test of xslt_set_object
--dviner
Diffstat (limited to 'ext/xslt')
-rw-r--r-- | ext/xslt/tests/008.phpt | 87 | ||||
-rw-r--r-- | ext/xslt/tests/xslt_set_object.xsl | 3 |
2 files changed, 90 insertions, 0 deletions
diff --git a/ext/xslt/tests/008.phpt b/ext/xslt/tests/008.phpt new file mode 100644 index 0000000000..a7e8b3d6d7 --- /dev/null +++ b/ext/xslt/tests/008.phpt @@ -0,0 +1,87 @@ +--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 diff --git a/ext/xslt/tests/xslt_set_object.xsl b/ext/xslt/tests/xslt_set_object.xsl new file mode 100644 index 0000000000..9618f42e21 --- /dev/null +++ b/ext/xslt/tests/xslt_set_object.xsl @@ -0,0 +1,3 @@ +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:import href="http://param.xsl" /> +</xsl:stylesheet> |