diff options
author | Felipe Pena <felipe@php.net> | 2009-07-02 00:04:52 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2009-07-02 00:04:52 +0000 |
commit | 634f233cc015a96cce89e10f2eefe24a3bb73a14 (patch) | |
tree | 0bb4bbd1b282dd9cd90c732131661de150497c15 /ext/dom | |
parent | 838d359641c5acd0b2e669520322f3d80c2a47d6 (diff) | |
download | php-git-634f233cc015a96cce89e10f2eefe24a3bb73a14.tar.gz |
- MFH: New tests (NorwayUG testfest)
Diffstat (limited to 'ext/dom')
-rw-r--r-- | ext/dom/tests/DOMDocument_createEntityReference_basic.phpt | 19 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt | 29 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt | 24 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt | 15 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt | 33 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt | 25 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTML_basic.phpt | 24 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTML_error1.phpt | 24 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_saveHTML_error2.phpt | 15 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_validate_basic.phpt | 31 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_validate_error1.phpt | 16 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_validate_error2.phpt | 15 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocument_validate_external_dtd.phpt | 19 |
13 files changed, 289 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMDocument_createEntityReference_basic.phpt b/ext/dom/tests/DOMDocument_createEntityReference_basic.phpt new file mode 100644 index 0000000000..4f4ddf1765 --- /dev/null +++ b/ext/dom/tests/DOMDocument_createEntityReference_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMDocument::createEntityReference() should create a new entity reference node +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$dom = new DOMDocument('1.0'); +$ref = $dom->createEntityReference('nbsp'); +$dom->appendChild($ref); +echo $dom->saveXML(); +?> +--EXPECTF-- +<?xml version="1.0"?> + diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt new file mode 100644 index 0000000000..dd0824b0d1 --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTMLFile_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +DOMDocument::saveHTMLFile() should dump the internal document into a file using HTML formatting +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html"; +$doc = new DOMDocument('1.0'); +$root = $doc->createElement('html'); +$root = $doc->appendChild($root); +$head = $doc->createElement('head'); +$head = $root->appendChild($head); +$title = $doc->createElement('title'); +$title = $head->appendChild($title); +$text = $doc->createTextNode('This is the title'); +$text = $title->appendChild($text); +$bytes = $doc->saveHTMLFile($filename); +var_dump($bytes); +echo file_get_contents($filename); +unlink($filename); +?> +--EXPECTF-- +int(126) +<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head></html> diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt new file mode 100644 index 0000000000..d4dfbe8fe0 --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTMLFile_error1.phpt @@ -0,0 +1,24 @@ +--TEST-- +DOMDocument::saveHTMLFile() should fail if no parameter is given +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once('skipif.inc'); +?> +--FILE-- +<?php +$doc = new DOMDocument('1.0'); +$root = $doc->createElement('html'); +$root = $doc->appendChild($root); +$head = $doc->createElement('head'); +$head = $root->appendChild($head); +$title = $doc->createElement('title'); +$title = $head->appendChild($title); +$text = $doc->createTextNode('This is the title'); +$text = $title->appendChild($text); +$doc->saveHTMLFile(); +?> +--EXPECTF-- +Warning: DOMDocument::saveHTMLFile() expects exactly 1 parameter, 0 given in %s on line %d diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt new file mode 100644 index 0000000000..33e07c641d --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTMLFile_error2.phpt @@ -0,0 +1,15 @@ +--TEST-- +DOMDocument::saveHTMLFile() should fail if called statically +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +DOMDocument::saveHTMLFile(); +?> +--EXPECTF-- +Fatal error: Non-static method DOMDocument::saveHTMLFile() cannot be called statically in %s on line %d diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt new file mode 100644 index 0000000000..5aece3780a --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTMLFile_formatOutput.phpt @@ -0,0 +1,33 @@ +--TEST-- +DOMDocument::saveHTMLFile() should format output on demand +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html"; +$doc = new DOMDocument('1.0'); +$doc->formatOutput = true; +$root = $doc->createElement('html'); +$root = $doc->appendChild($root); +$head = $doc->createElement('head'); +$head = $root->appendChild($head); +$title = $doc->createElement('title'); +$title = $head->appendChild($title); +$text = $doc->createTextNode('This is the title'); +$text = $title->appendChild($text); +$bytes = $doc->saveHTMLFile($filename); +var_dump($bytes); +echo file_get_contents($filename); +unlink($filename); +?> +--EXPECTF-- +int(129) +<html><head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>This is the title</title> +</head></html> diff --git a/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt b/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt new file mode 100644 index 0000000000..d5c6a797ef --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTMLFile_invalid_filename.phpt @@ -0,0 +1,25 @@ +--TEST-- +DOMDocument::saveHTMLFile() should fail with invalid filename +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$filename = null; +$doc = new DOMDocument('1.0'); +$root = $doc->createElement('html'); +$root = $doc->appendChild($root); +$head = $doc->createElement('head'); +$head = $root->appendChild($head); +$title = $doc->createElement('title'); +$title = $head->appendChild($title); +$text = $doc->createTextNode('This is the title'); +$text = $title->appendChild($text); +$bytes = $doc->saveHTMLFile($filename); +?> +--EXPECTF-- +Warning: DOMDocument::saveHTMLFile(): Invalid Filename in %s on line %d diff --git a/ext/dom/tests/DOMDocument_saveHTML_basic.phpt b/ext/dom/tests/DOMDocument_saveHTML_basic.phpt new file mode 100644 index 0000000000..76f1ed0abf --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTML_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +DOMDocument::saveHTML() should dump the internal document into a string using HTML formatting +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$doc = new DOMDocument('1.0'); +$root = $doc->createElement('html'); +$root = $doc->appendChild($root); +$head = $doc->createElement('head'); +$head = $root->appendChild($head); +$title = $doc->createElement('title'); +$title = $head->appendChild($title); +$text = $doc->createTextNode('This is the title'); +$text = $title->appendChild($text); +echo $doc->saveHTML(); +?> +--EXPECTF-- +<html><head><title>This is the title</title></head></html> diff --git a/ext/dom/tests/DOMDocument_saveHTML_error1.phpt b/ext/dom/tests/DOMDocument_saveHTML_error1.phpt new file mode 100644 index 0000000000..78718de8e7 --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTML_error1.phpt @@ -0,0 +1,24 @@ +--TEST-- +DOMDocument::saveHTML() should fail if a parameter is given +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once('skipif.inc'); +?> +--FILE-- +<?php +$doc = new DOMDocument('1.0'); +$root = $doc->createElement('html'); +$root = $doc->appendChild($root); +$head = $doc->createElement('head'); +$head = $root->appendChild($head); +$title = $doc->createElement('title'); +$title = $head->appendChild($title); +$text = $doc->createTextNode('This is the title'); +$text = $title->appendChild($text); +echo $doc->saveHTML(true); +?> +--EXPECTF-- +Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/dom/tests/DOMDocument_saveHTML_error2.phpt b/ext/dom/tests/DOMDocument_saveHTML_error2.phpt new file mode 100644 index 0000000000..614605b34a --- /dev/null +++ b/ext/dom/tests/DOMDocument_saveHTML_error2.phpt @@ -0,0 +1,15 @@ +--TEST-- +DOMDocument::saveHTML() should fail if called statically +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +DOMDocument::saveHTML(true); +?> +--EXPECTF-- +Fatal error: Non-static method DOMDocument::saveHTML() cannot be called statically in %s on line %d diff --git a/ext/dom/tests/DOMDocument_validate_basic.phpt b/ext/dom/tests/DOMDocument_validate_basic.phpt new file mode 100644 index 0000000000..7c0eec8ddd --- /dev/null +++ b/ext/dom/tests/DOMDocument_validate_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +DOMDocument::validate() should validate an internal DTD declaration +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$xml = "<?xml version=\"1.0\"?> +<!DOCTYPE note [ +<!ELEMENT note (to,from,heading,body)> +<!ELEMENT to (#PCDATA)> +<!ELEMENT from (#PCDATA)> +<!ELEMENT heading (#PCDATA)> +<!ELEMENT body (#PCDATA)> +]> +<note> +<to>Tove</to> +<from>Jani</from> +<heading>Reminder</heading> +<body>Don't forget me this weekend</body> +</note>"; +$dom = new DOMDocument('1.0'); +$dom->loadXML($xml); +var_dump($dom->validate()); +?> +--EXPECTF-- +bool(true) diff --git a/ext/dom/tests/DOMDocument_validate_error1.phpt b/ext/dom/tests/DOMDocument_validate_error1.phpt new file mode 100644 index 0000000000..8e1e72fe0f --- /dev/null +++ b/ext/dom/tests/DOMDocument_validate_error1.phpt @@ -0,0 +1,16 @@ +--TEST-- +DOMDocument::validate() should fail if any parameter is given +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +$dom = new DOMDocument('1.0'); +$dom->validate(true); +?> +--EXPECTF-- +Warning: DOMDocument::validate() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/dom/tests/DOMDocument_validate_error2.phpt b/ext/dom/tests/DOMDocument_validate_error2.phpt new file mode 100644 index 0000000000..fe7e4fc9d9 --- /dev/null +++ b/ext/dom/tests/DOMDocument_validate_error2.phpt @@ -0,0 +1,15 @@ +--TEST-- +DOMDocument::validate() should fail if called statically +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +DOMDocument::validate(); +?> +--EXPECTF-- +Fatal error: Non-static method DOMDocument::validate() cannot be called statically in %s on line %d diff --git a/ext/dom/tests/DOMDocument_validate_external_dtd.phpt b/ext/dom/tests/DOMDocument_validate_external_dtd.phpt new file mode 100644 index 0000000000..51a044c54a --- /dev/null +++ b/ext/dom/tests/DOMDocument_validate_external_dtd.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMDocument::validate() should validate an external DTD declaration +--CREDITS-- +Knut Urdalen <knut@php.net> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--SKIPIF-- +<?php +require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php +// reusing existing xml: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/dom.xml?view=co&content-type=text%2Fplain +// reusing existing dtd: http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/dom.ent?view=co&content-type=text%2Fplain +$dom = new DOMDocument('1.0'); +$dom->load(dirname(__FILE__).'/dom.xml'); +var_dump($dom->validate()); +?> +--EXPECTF-- +bool(true) |