]> granicus.if.org Git - php/commitdiff
some tests (test #3 is currently broken due to memleak, fix is on the way)
authorChristian Stocker <chregu@php.net>
Mon, 27 Oct 2003 08:46:55 +0000 (08:46 +0000)
committerChristian Stocker <chregu@php.net>
Mon, 27 Oct 2003 08:46:55 +0000 (08:46 +0000)
ext/xsl/tests/prepare.inc [new file with mode: 0644]
ext/xsl/tests/xslt.xml [new file with mode: 0644]
ext/xsl/tests/xslt.xsl [new file with mode: 0644]
ext/xsl/tests/xslt001.phpt [new file with mode: 0644]
ext/xsl/tests/xslt002.phpt [new file with mode: 0644]
ext/xsl/tests/xslt003.phpt [new file with mode: 0644]
ext/xsl/tests/xslt004.phpt [new file with mode: 0644]
ext/xsl/tests/xslt005.phpt [new file with mode: 0644]
ext/xsl/tests/xslt006.phpt [new file with mode: 0644]
ext/xsl/tests/xslt007.phpt [new file with mode: 0644]

diff --git a/ext/xsl/tests/prepare.inc b/ext/xsl/tests/prepare.inc
new file mode 100644 (file)
index 0000000..c2e76fd
--- /dev/null
@@ -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;
+}
+
+?>
diff --git a/ext/xsl/tests/xslt.xml b/ext/xsl/tests/xslt.xml
new file mode 100644 (file)
index 0000000..b0e9506
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt.xsl b/ext/xsl/tests/xslt.xsl
new file mode 100644 (file)
index 0000000..6248a28
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt001.phpt b/ext/xsl/tests/xslt001.phpt
new file mode 100644 (file)
index 0000000..d58ed62
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt002.phpt b/ext/xsl/tests/xslt002.phpt
new file mode 100644 (file)
index 0000000..2c111b2
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt003.phpt b/ext/xsl/tests/xslt003.phpt
new file mode 100644 (file)
index 0000000..222c61f
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt004.phpt b/ext/xsl/tests/xslt004.phpt
new file mode 100644 (file)
index 0000000..766bcd1
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt005.phpt b/ext/xsl/tests/xslt005.phpt
new file mode 100644 (file)
index 0000000..62164b9
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt006.phpt b/ext/xsl/tests/xslt006.phpt
new file mode 100644 (file)
index 0000000..1cb01fb
--- /dev/null
@@ -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>
diff --git a/ext/xsl/tests/xslt007.phpt b/ext/xsl/tests/xslt007.phpt
new file mode 100644 (file)
index 0000000..da05f83
--- /dev/null
@@ -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>