diff options
author | Zoe Slattery <zoe@php.net> | 2009-08-30 09:30:13 +0000 |
---|---|---|
committer | Zoe Slattery <zoe@php.net> | 2009-08-30 09:30:13 +0000 |
commit | 6a22ec3edabebbe57f53d6f42aacbd5ad97ad7ba (patch) | |
tree | 4d0202e6e7603adf5326a9fb1fd435d702dfc7e7 /ext/dom | |
parent | 94039c35b9183df5093c4cd6f868dad7b253bfde (diff) | |
download | php-git-6a22ec3edabebbe57f53d6f42aacbd5ad97ad7ba.tar.gz |
More tests from 2009 testfest
Diffstat (limited to 'ext/dom')
-rw-r--r-- | ext/dom/tests/DOMDocument_documentURI_basic.phpt | 39 | ||||
-rwxr-xr-x | ext/dom/tests/DOMDocument_schemaValidateSource_error1.phpt | 29 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_standalone_basic.phpt | 48 |
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 |