mirror of
https://github.com/php/php-src.git
synced 2024-12-13 20:05:26 +08:00
some tests (test #3 is currently broken due to memleak, fix is on the way)
This commit is contained in:
parent
dcc060382a
commit
acd5eb24db
20
ext/xsl/tests/prepare.inc
Normal file
20
ext/xsl/tests/prepare.inc
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
$dom = new domDocument;
|
||||
$dom->load(dirname(__FILE__)."/xslt.xml");
|
||||
if(!$dom) {
|
||||
echo "Error while parsing the document\n";
|
||||
exit;
|
||||
}
|
||||
$xsl = new domDocument;
|
||||
$xsl->load(dirname(__FILE__)."/xslt.xsl");
|
||||
if(!$xsl) {
|
||||
echo "Error while parsing the document\n";
|
||||
exit;
|
||||
}
|
||||
$proc = new xsltprocessor;
|
||||
if(!$xsl) {
|
||||
echo "Error while making xsltprocessor object\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
28
ext/xsl/tests/xslt.xml
Normal file
28
ext/xsl/tests/xslt.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version='1.0' encoding="iso-8859-1" ?>
|
||||
<chapter language="en">
|
||||
<title language="en">Title</title>
|
||||
<para language="ge">
|
||||
|
||||
<!-- comment -->
|
||||
<informaltable>
|
||||
<tgroup cols="3">
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>a1</entry>
|
||||
<entry morerows="1">b1</entry>
|
||||
<entry>c1</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>a2</entry>
|
||||
<entry>c2</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ä3</entry>
|
||||
<entry>b3</entry>
|
||||
<entry>c3</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
</chapter>
|
25
ext/xsl/tests/xslt.xsl
Normal file
25
ext/xsl/tests/xslt.xsl
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Id: xslt.xsl,v 1.1 2003-10-27 08:46:55 chregu Exp $ -->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
|
||||
<xsl:output method="xml" encoding="iso-8859-1" indent="no"/>
|
||||
<xsl:param name="foo" select="'bar'"/>
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<body>
|
||||
<xsl:value-of select="$foo"/><xsl:text>
|
||||
</xsl:text>
|
||||
<xsl:apply-templates select="/chapter/para/informaltable/tgroup/tbody/row"/>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="row">
|
||||
<xsl:for-each select="entry">
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:for-each>
|
||||
<br/> <xsl:text>
|
||||
</xsl:text>
|
||||
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
20
ext/xsl/tests/xslt001.phpt
Normal file
20
ext/xsl/tests/xslt001.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Test 1: Transform To XML String
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 1: Transform To XML String";
|
||||
include("prepare.inc");
|
||||
$proc->importStylesheet($xsl);
|
||||
print "\n";
|
||||
print $proc->transformToXml($dom);
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 1: Transform To XML String
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<html><body>bar
|
||||
a1 b1 c1 <br/>
|
||||
a2 c2 <br/>
|
||||
ä3 b3 c3 <br/>
|
||||
</body></html>
|
27
ext/xsl/tests/xslt002.phpt
Normal file
27
ext/xsl/tests/xslt002.phpt
Normal file
@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Test 2: Transform To HTML String
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 2: Transform To HTML String";
|
||||
include("prepare.inc");
|
||||
// changing output method to html
|
||||
$xp = new domxpath($xsl);
|
||||
$res = $xp->query("/xsl:stylesheet/xsl:output/@method");
|
||||
if (count($res) != 1) {
|
||||
print "No or more than one xsl:output/@method found";
|
||||
exit;
|
||||
}
|
||||
$res[0]->value = "html";
|
||||
$proc->importStylesheet($xsl);
|
||||
print "\n";
|
||||
print $proc->transformToXml($dom);
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 2: Transform To HTML String
|
||||
<html><body>bar
|
||||
a1 b1 c1 <br>
|
||||
a2 c2 <br>
|
||||
ä3 b3 c3 <br>
|
||||
</body></html>
|
21
ext/xsl/tests/xslt003.phpt
Normal file
21
ext/xsl/tests/xslt003.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Test 1: Using Parameters
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 1: Using Parameters";
|
||||
include("prepare.inc");
|
||||
$proc->importStylesheet($xsl);
|
||||
$proc->setParameter( "", "foo","hello world");
|
||||
print "\n";
|
||||
print $proc->transformToXml($dom);
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 1: Transform To XML String
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<html><body>bar
|
||||
a1 b1 c1 <br/>
|
||||
a2 c2 <br/>
|
||||
a3 b3 c3 <br/>
|
||||
</body></html>
|
27
ext/xsl/tests/xslt004.phpt
Normal file
27
ext/xsl/tests/xslt004.phpt
Normal file
@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Test 4: Checking UTF8 Output
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 4: Checking UTF8 Output";
|
||||
include("prepare.inc");
|
||||
$xp = new domxpath($xsl);
|
||||
$res = $xp->query("/xsl:stylesheet/xsl:output/@encoding");
|
||||
if (count($res) != 1) {
|
||||
print "No or more than one xsl:output/@encoding found";
|
||||
exit;
|
||||
}
|
||||
$res[0]->value = "utf-8";
|
||||
$proc->importStylesheet($xsl);
|
||||
print "\n";
|
||||
print $proc->transformToXml($dom);
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 4: Checking UTF8 Output
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<html><body>bar
|
||||
a1 b1 c1 <br/>
|
||||
a2 c2 <br/>
|
||||
ä3 b3 c3 <br/>
|
||||
</body></html>
|
29
ext/xsl/tests/xslt005.phpt
Normal file
29
ext/xsl/tests/xslt005.phpt
Normal file
@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Test 5: Checking Indent
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 5: Checking Indent";
|
||||
include("prepare.inc");
|
||||
$xp = new domxpath($xsl);
|
||||
$res = $xp->query("/xsl:stylesheet/xsl:output/@indent");
|
||||
if (count($res) != 1) {
|
||||
print "No or more than one xsl:output/@indent found";
|
||||
exit;
|
||||
}
|
||||
$res[0]->value = "yes";
|
||||
$proc->importStylesheet($xsl);
|
||||
print "\n";
|
||||
print $proc->transformToXml($dom);
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 5: Checking Indent
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<html>
|
||||
<body>bar
|
||||
a1 b1 c1 <br/>
|
||||
a2 c2 <br/>
|
||||
ä3 b3 c3 <br/>
|
||||
</body>
|
||||
</html>
|
21
ext/xsl/tests/xslt006.phpt
Normal file
21
ext/xsl/tests/xslt006.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Test 6: Transform To Doc
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 6: Transform To Doc";
|
||||
include("prepare.inc");
|
||||
$proc->importStylesheet($xsl);
|
||||
print "\n";
|
||||
$doc = $proc->transformToDoc($dom);
|
||||
print $doc->saveXML();
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 6: Transform To Doc
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<html><body>bar
|
||||
a1 b1 c1 <br/>
|
||||
a2 c2 <br/>
|
||||
ä3 b3 c3 <br/>
|
||||
</body></html>
|
22
ext/xsl/tests/xslt007.phpt
Normal file
22
ext/xsl/tests/xslt007.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Test 7: Transform To Uri
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test 7: Transform To Uri";
|
||||
include("prepare.inc");
|
||||
$proc->importStylesheet($xsl);
|
||||
print "\n";
|
||||
$doc = $proc->transformToUri($dom, "file://".dirname(__FILE__)."/out.xml");
|
||||
print file_get_contents(dirname(__FILE__)."/out.xml");
|
||||
unlink(dirname(__FILE__)."/out.xml");
|
||||
print "\n";
|
||||
|
||||
|
||||
--EXPECT--
|
||||
Test 7: Transform To Uri
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<html><body>bar
|
||||
a1 b1 c1 <br/>
|
||||
a2 c2 <br/>
|
||||
ä3 b3 c3 <br/>
|
||||
</body></html>
|
Loading…
Reference in New Issue
Block a user