summaryrefslogtreecommitdiff
path: root/ext/dom
diff options
context:
space:
mode:
authorZoe Slattery <zoe@php.net>2009-08-30 09:30:13 +0000
committerZoe Slattery <zoe@php.net>2009-08-30 09:30:13 +0000
commit6a22ec3edabebbe57f53d6f42aacbd5ad97ad7ba (patch)
tree4d0202e6e7603adf5326a9fb1fd435d702dfc7e7 /ext/dom
parent94039c35b9183df5093c4cd6f868dad7b253bfde (diff)
downloadphp-git-6a22ec3edabebbe57f53d6f42aacbd5ad97ad7ba.tar.gz
More tests from 2009 testfest
Diffstat (limited to 'ext/dom')
-rw-r--r--ext/dom/tests/DOMDocument_documentURI_basic.phpt39
-rwxr-xr-xext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt29
-rw-r--r--ext/dom/tests/DOMDocument_standalone_basic.phpt48
3 files changed, 116 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMDocument_documentURI_basic.phpt b/ext/dom/tests/DOMDocument_documentURI_basic.phpt
new file mode 100644
index 0000000000..e40a42b964
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_documentURI_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Tests DOMDocument::documentURI read and write
+--CREDITS--
+Chris Snyder <chsnyder@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// create dom document
+$dom = new DOMDocument;
+$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
+<s1>foo</s1>';
+$dom->loadXML($xml);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+echo "DOMDocument created\n";
+
+$test = $dom->documentURI;
+echo "Read initial documentURI:\n";
+echo $test."\n";
+
+$dom->documentURI = 'http://dom.example.org/example.xml';
+$test = $dom->documentURI;
+echo "Set documentURI to a URL, reading again:\n";
+var_dump( $test );
+
+echo "Done\n";
+?>
+--EXPECTF--
+DOMDocument created
+Read initial documentURI:
+%s
+Set documentURI to a URL, reading again:
+string(34) "http://dom.example.org/example.xml"
+Done
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt
new file mode 100755
index 0000000000..51eb82e32f
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt
@@ -0,0 +1,29 @@
+--TEST--
+DomDocument::schemaValidateSource() - string that is not a schema
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book.xml");
+
+$result = $doc->schemaValidateSource('string that is not a schema');
+var_dump($result);
+
+?>
+--EXPECTF--
+Warning: DOMDocument::schemaValidateSource(): Entity: line 1: parser error : Start tag expected, '<' not found in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): string that is not a schema in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): ^ in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): Failed to parse the XML resource 'in_memory_buffer'. in %s.php on line %d
+
+Warning: DOMDocument::schemaValidateSource(): Invalid Schema in %s.php on line %d
+bool(false)
diff --git a/ext/dom/tests/DOMDocument_standalone_basic.phpt b/ext/dom/tests/DOMDocument_standalone_basic.phpt
new file mode 100644
index 0000000000..2316a3897d
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_standalone_basic.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Tests DOMDocument::standalone get, set, and functionality
+--CREDITS--
+Chris Snyder <chsnyder@gmail.com>
+# TestFest 2009 NYPHP
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+// create dom document
+$dom = new DOMDocument;
+$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
+<s1>foo</s1>';
+$dom->loadXML($xml);
+if(!$dom) {
+ echo "Error while parsing the document\n";
+ exit;
+}
+echo "Standalone DOMDocument created\n";
+
+$test = $dom->standalone;
+echo "Read initial standalone:\n";
+var_dump( $test );
+
+$dom->standalone = FALSE;
+$test = $dom->standalone;
+echo "Set standalone to FALSE, reading again:\n";
+var_dump( $test );
+
+$test = $dom->saveXML();
+echo "Document is no longer standalone\n";
+var_dump( $test );
+
+echo "Done";
+?>
+--EXPECT--
+Standalone DOMDocument created
+Read initial standalone:
+bool(true)
+Set standalone to FALSE, reading again:
+bool(false)
+Document is no longer standalone
+string(136) "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
+<s1>foo</s1>
+"
+Done \ No newline at end of file