diff --git a/ext/xsl/tests/prepare.inc b/ext/xsl/tests/prepare.inc new file mode 100644 index 00000000000..c2e76fd4b3f --- /dev/null +++ b/ext/xsl/tests/prepare.inc @@ -0,0 +1,20 @@ +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 index 00000000000..b0e9506c7bf --- /dev/null +++ b/ext/xsl/tests/xslt.xml @@ -0,0 +1,28 @@ + + + Title + + + + + + + + a1 + b1 + c1 + + + a2 + c2 + + + ä3 + b3 + c3 + + + + + + diff --git a/ext/xsl/tests/xslt.xsl b/ext/xsl/tests/xslt.xsl new file mode 100644 index 00000000000..6248a28580b --- /dev/null +++ b/ext/xsl/tests/xslt.xsl @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + +
+ + +
+
diff --git a/ext/xsl/tests/xslt001.phpt b/ext/xsl/tests/xslt001.phpt new file mode 100644 index 00000000000..d58ed625a00 --- /dev/null +++ b/ext/xsl/tests/xslt001.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test 1: Transform To XML String +--FILE-- +importStylesheet($xsl); +print "\n"; +print $proc->transformToXml($dom); +print "\n"; + + +--EXPECT-- +Test 1: Transform To XML String + +bar +a1 b1 c1
+a2 c2
+ä3 b3 c3
+ diff --git a/ext/xsl/tests/xslt002.phpt b/ext/xsl/tests/xslt002.phpt new file mode 100644 index 00000000000..2c111b22f2e --- /dev/null +++ b/ext/xsl/tests/xslt002.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test 2: Transform To HTML String +--FILE-- +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 +bar +a1 b1 c1
+a2 c2
+ä3 b3 c3
+ diff --git a/ext/xsl/tests/xslt003.phpt b/ext/xsl/tests/xslt003.phpt new file mode 100644 index 00000000000..222c61ff1fb --- /dev/null +++ b/ext/xsl/tests/xslt003.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test 1: Using Parameters +--FILE-- +importStylesheet($xsl); +$proc->setParameter( "", "foo","hello world"); +print "\n"; +print $proc->transformToXml($dom); +print "\n"; + + +--EXPECT-- +Test 1: Transform To XML String + +bar +a1 b1 c1
+a2 c2
+a3 b3 c3
+ diff --git a/ext/xsl/tests/xslt004.phpt b/ext/xsl/tests/xslt004.phpt new file mode 100644 index 00000000000..766bcd103e6 --- /dev/null +++ b/ext/xsl/tests/xslt004.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test 4: Checking UTF8 Output +--FILE-- +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 + +bar +a1 b1 c1
+a2 c2
+ä3 b3 c3
+ diff --git a/ext/xsl/tests/xslt005.phpt b/ext/xsl/tests/xslt005.phpt new file mode 100644 index 00000000000..62164b9bffd --- /dev/null +++ b/ext/xsl/tests/xslt005.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test 5: Checking Indent +--FILE-- +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 + + + bar +a1 b1 c1
+a2 c2
+ä3 b3 c3
+ + diff --git a/ext/xsl/tests/xslt006.phpt b/ext/xsl/tests/xslt006.phpt new file mode 100644 index 00000000000..1cb01fba914 --- /dev/null +++ b/ext/xsl/tests/xslt006.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test 6: Transform To Doc +--FILE-- +importStylesheet($xsl); +print "\n"; +$doc = $proc->transformToDoc($dom); +print $doc->saveXML(); +print "\n"; + + +--EXPECT-- +Test 6: Transform To Doc + +bar +a1 b1 c1
+a2 c2
+ä3 b3 c3
+ diff --git a/ext/xsl/tests/xslt007.phpt b/ext/xsl/tests/xslt007.phpt new file mode 100644 index 00000000000..da05f837901 --- /dev/null +++ b/ext/xsl/tests/xslt007.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test 7: Transform To Uri +--FILE-- +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 + +bar +a1 b1 c1
+a2 c2
+ä3 b3 c3
+