From 951d4c6e7fbae80042f79632293e05cbb43101a5 Mon Sep 17 00:00:00 2001 From: Antonio Diaz Ruiz Date: Mon, 6 May 2013 23:01:18 +0200 Subject: [PATCH] PHPTests for the DOMDocument::loadHTMLfile method. They cover - The basic behaviour - When the method receives as argument a file which doesn't exist - When the argument is an empty string - When an empty file is loaded - When a not-well formed html file is loaded It also includes 2 auxilary files - An empty html file - A not well formed html file --- ext/dom/tests/DOMDocument_loadHTMLfile.phpt | 17 +++++++++++++++++ .../tests/DOMDocument_loadHTMLfile_error1.phpt | 18 ++++++++++++++++++ .../tests/DOMDocument_loadHTMLfile_error2.phpt | 18 ++++++++++++++++++ .../DOMDocument_loadHTMLfile_variation1.phpt | 18 ++++++++++++++++++ .../DOMDocument_loadHTMLfile_variation2.phpt | 17 +++++++++++++++++ ext/dom/tests/empty.html | 0 ext/dom/tests/not_well.html | 8 ++++++++ 7 files changed, 96 insertions(+) create mode 100644 ext/dom/tests/DOMDocument_loadHTMLfile.phpt create mode 100644 ext/dom/tests/DOMDocument_loadHTMLfile_error1.phpt create mode 100644 ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt create mode 100644 ext/dom/tests/DOMDocument_loadHTMLfile_variation1.phpt create mode 100644 ext/dom/tests/DOMDocument_loadHTMLfile_variation2.phpt create mode 100644 ext/dom/tests/empty.html create mode 100644 ext/dom/tests/not_well.html diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile.phpt new file mode 100644 index 0000000000000..93a614903f781 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadHTMLfile.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test DOMDocument::loadHTMLFile +--DESCRIPTION-- +Verifies the basic behaviour of the method +--CREDITS-- +Antonio Diaz Ruiz +--INI-- +assert.bail=true +--SKIPIF-- + +--FILE-- +loadHTMLFile(dirname(__FILE__) . "/test.html"); +assert('$result === true'); +?> +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile_error1.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile_error1.phpt new file mode 100644 index 0000000000000..aee51966a3e4d --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadHTMLfile_error1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test DOMDocument::loadHTMLFile when the file doesn't exist +--DESCRIPTION-- +Verifies that an error message is showed if the file doesn't exist +--CREDITS-- +Antonio Diaz Ruiz +--INI-- +assert.bail=true +--SKIPIF-- + +--FILE-- +loadHTMLFile(dirname(__FILE__) . "/ffff/test.html"); +assert('$result === false'); +?> +--EXPECTF-- +%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity %s diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt new file mode 100644 index 0000000000000..e59ff56c5a831 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test DOMDocument::loadHTMLFile when an empty string is passed +--DESCRIPTION-- +Verifies that an error message is showed if an empty string is passed as argument +--CREDITS-- +Antonio Diaz Ruiz +--INI-- +assert.bail=true +--SKIPIF-- + +--FILE-- +loadHTMLFile(""); +assert('$result === false'); +?> +--EXPECTF-- +%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Empty string supplied as input %s diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile_variation1.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile_variation1.phpt new file mode 100644 index 0000000000000..2535772c78806 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadHTMLfile_variation1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test DOMDocument::loadHTMLFile when an empty document is loaded +--DESCRIPTION-- +Verifies that an warning message is showed if an empty document is loaded +--CREDITS-- +Antonio Diaz Ruiz +--INI-- +assert.bail=true +--SKIPIF-- + +--FILE-- +loadHTMLFile(dirname(__FILE__) . "/empty.html"); +assert('$result === true'); +?> +--EXPECTF-- +%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Document is empty %s diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile_variation2.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile_variation2.phpt new file mode 100644 index 0000000000000..829686dd65fe3 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadHTMLfile_variation2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test DOMDocument::loadHTMLFile when a not-well formed document is loaded +--DESCRIPTION-- +Verifies the behavior if a not-well formed document is loaded +--CREDITS-- +Antonio Diaz Ruiz +--INI-- +assert.bail=true +--SKIPIF-- + +--FILE-- +loadHTMLFile(dirname(__FILE__) . "/not_well.html"); +assert('$result === true'); +?> +--EXPECT-- diff --git a/ext/dom/tests/empty.html b/ext/dom/tests/empty.html new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/ext/dom/tests/not_well.html b/ext/dom/tests/not_well.html new file mode 100644 index 0000000000000..151f46295fdf3 --- /dev/null +++ b/ext/dom/tests/not_well.html @@ -0,0 +1,8 @@ + +Hello world + + +This is a not well-formed
+html files with undeclared entities  + +