summaryrefslogtreecommitdiff
path: root/ext/dom/tests
diff options
context:
space:
mode:
authorAntonio Diaz Ruiz <dejalatele@gmail.com>2013-06-14 23:11:08 +0200
committerStanislav Malyshev <stas@php.net>2013-08-10 18:01:54 -0700
commit24f36934ad4b9d00a4c96da252497a4091bb28e6 (patch)
tree502647d53f2e096cd058f225bfe8ebfda3c74838 /ext/dom/tests
parent473d66553d64f1b76ba969eabb105b1fdc7497b1 (diff)
downloadphp-git-24f36934ad4b9d00a4c96da252497a4091bb28e6.tar.gz
Adds files: error 1 to 5 and variation 1 to 4
tests for error1: not well formed xml tests for error2: not well formed xml attribute without colon tests for error2: not well formed xml, typo tests for error4: wrong xml version tests for error5: extra content at the end of the doc tests libxml_dtd_load tests libxml_dtd_valid tests for libdtd_noerror tests for LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT and LIBXML_NOBLANKS the basic behavior fix comments
Diffstat (limited to 'ext/dom/tests')
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_basic.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_error1.phpt26
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_error2.phpt30
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_error3.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_error4.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_error5.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_variation1.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_variation2.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_variation3.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_loadXML_variation4.phpt25
-rw-r--r--ext/dom/tests/DOMDocument_load_basic.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_load_error1.phpt26
-rw-r--r--ext/dom/tests/DOMDocument_load_error2.phpt30
-rw-r--r--ext/dom/tests/DOMDocument_load_error3.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_load_error4.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_load_error5.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_load_variation1.phpt21
-rw-r--r--ext/dom/tests/DOMDocument_load_variation2.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_load_variation3.phpt22
-rw-r--r--ext/dom/tests/DOMDocument_load_variation4.phpt25
-rw-r--r--ext/dom/tests/book_with_dtd.xml16
-rw-r--r--ext/dom/tests/books.dtd7
-rw-r--r--ext/dom/tests/domdocumentload_test_method.php12
-rw-r--r--ext/dom/tests/domdocumentload_test_method_savexml.php14
-rw-r--r--ext/dom/tests/domdocumentload_utilities.php16
-rw-r--r--ext/dom/tests/domdocumentloadxml_test_method.php12
-rw-r--r--ext/dom/tests/domdocumentloadxml_test_method_savexml.php14
-rw-r--r--ext/dom/tests/not_well_formed.xml12
-rw-r--r--ext/dom/tests/not_well_formed2.xml12
-rw-r--r--ext/dom/tests/not_well_formed3.xml12
-rw-r--r--ext/dom/tests/not_well_formed4.xml12
-rw-r--r--ext/dom/tests/not_well_formed5.xml10
-rw-r--r--ext/dom/tests/wrong_book_with_dtd.xml13
33 files changed, 628 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMDocument_loadXML_basic.phpt b/ext/dom/tests/DOMDocument_loadXML_basic.phpt
new file mode 100644
index 0000000000..569593c007
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test DOMDocument::loadXML() basic behavior
+--DESCRIPTION--
+This test verifies the basic behaviour of the method
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/book.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECT--
diff --git a/ext/dom/tests/DOMDocument_loadXML_error1.phpt b/ext/dom/tests/DOMDocument_loadXML_error1.phpt
new file mode 100644
index 0000000000..52d44ea291
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_error1.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Test DOMDocument::loadXML() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects an opening and ending tag mismatch
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: title line 5 and book %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): expected '>' %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Premature end of data in tag books %s
diff --git a/ext/dom/tests/DOMDocument_loadXML_error2.phpt b/ext/dom/tests/DOMDocument_loadXML_error2.phpt
new file mode 100644
index 0000000000..6ac4193daf
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_error2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test DOMDocument::loadXML() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects attributes values not closed between " or '
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed2.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): AttValue: " or ' expected %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): attributes construct error %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Couldn't find end of Start Tag book %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: books %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
diff --git a/ext/dom/tests/DOMDocument_loadXML_error3.phpt b/ext/dom/tests/DOMDocument_loadXML_error3.phpt
new file mode 100644
index 0000000000..07f7ca7738
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_error3.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::loadXML() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects a typo in tag names
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed3.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: boOk line 8 and book %s
diff --git a/ext/dom/tests/DOMDocument_loadXML_error4.phpt b/ext/dom/tests/DOMDocument_loadXML_error4.phpt
new file mode 100644
index 0000000000..e35d3dcea5
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_error4.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::loadXML() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects an unsupported xml version
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed4.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Unsupported version '3.1' %s
diff --git a/ext/dom/tests/DOMDocument_loadXML_error5.phpt b/ext/dom/tests/DOMDocument_loadXML_error5.phpt
new file mode 100644
index 0000000000..a4aa1858f5
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_error5.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::loadXML() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects extra content at the end of the document
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed5.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
diff --git a/ext/dom/tests/DOMDocument_loadXML_variation1.phpt b/ext/dom/tests/DOMDocument_loadXML_variation1.phpt
new file mode 100644
index 0000000000..eb5c693e42
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_variation1.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test DOMDocument::loadXML() with LIBXML_DTDLOAD option
+--DESCRIPTION--
+This test verifies the right behaviour of the LIBXML_DTDLOAD constant
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDLOAD
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECT--
diff --git a/ext/dom/tests/DOMDocument_loadXML_variation2.phpt b/ext/dom/tests/DOMDocument_loadXML_variation2.phpt
new file mode 100644
index 0000000000..a1e6e80220
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_variation2.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::loadXML() with LIBXML_DTDVALID option
+--DESCRIPTION--
+This test verifies the right behaviour of the LIBXML_DTDVALID constant
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/wrong_book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDVALID
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Element book content does not follow the DTD, expecting (title , author), got (title author author ) %s
diff --git a/ext/dom/tests/DOMDocument_loadXML_variation3.phpt b/ext/dom/tests/DOMDocument_loadXML_variation3.phpt
new file mode 100644
index 0000000000..8e61ec4dbc
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_variation3.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::loadXML() with LIBXML_DTDVALID and LIBXML_NOERROR options
+--DESCRIPTION--
+This test vrifies the right behaviour of the LIBXML_NOERROR constant
+which avoids the display of the warning message
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/wrong_book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDVALID | LIBXML_NOERROR
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method.php
+--EXPECT--
diff --git a/ext/dom/tests/DOMDocument_loadXML_variation4.phpt b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt
new file mode 100644
index 0000000000..6adefa8414
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test DOMDocument::loadXML() with LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT, LIBXML_NOBLANKS
+--DESCRIPTION--
+This test verifies the right behaviour of the following constants:
+LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT and LIBXML_NOBLANKS
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDATTR|LIBXML_NOCDATA|LIBXML_NOENT|LIBXML_NOBLANKS
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentloadxml_test_method_savexml.php
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE books SYSTEM "books.dtd">
+<books><book><title default="default title">The Grapes of Wrath</title><author>John Steinbeck</author></book><book><title default="default title">The Pearl</title><author>John Steinbeck</author></book><book><title default="default title">entity is only for test purposes</title><author>data for test</author></book></books>
diff --git a/ext/dom/tests/DOMDocument_load_basic.phpt b/ext/dom/tests/DOMDocument_load_basic.phpt
new file mode 100644
index 0000000000..6d70ed4522
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test DOMDocument::load() basic behavior
+--DESCRIPTION--
+This test verifies the basic behaviour of the method
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/book.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECT--
diff --git a/ext/dom/tests/DOMDocument_load_error1.phpt b/ext/dom/tests/DOMDocument_load_error1.phpt
new file mode 100644
index 0000000000..2ac3f50979
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_error1.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Test DOMDocument::load() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects an opening and ending tag mismatch
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: title line 5 and book %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): expected '>' %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Premature end of data in tag books %s
diff --git a/ext/dom/tests/DOMDocument_load_error2.phpt b/ext/dom/tests/DOMDocument_load_error2.phpt
new file mode 100644
index 0000000000..23a5e4827d
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_error2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test DOMDocument::load() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects attributes values not closed between " or '
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed2.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): AttValue: " or ' expected %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): attributes construct error %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Couldn't find end of Start Tag book %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: books %s
+
+Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
diff --git a/ext/dom/tests/DOMDocument_load_error3.phpt b/ext/dom/tests/DOMDocument_load_error3.phpt
new file mode 100644
index 0000000000..b9ac49c466
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_error3.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::load() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects and opening and ending tag mismatch
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed3.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: boOk line 8 and book %s
diff --git a/ext/dom/tests/DOMDocument_load_error4.phpt b/ext/dom/tests/DOMDocument_load_error4.phpt
new file mode 100644
index 0000000000..ca9ed79a3e
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_error4.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::load() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects an unsupported xml version
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed4.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Unsupported version '3.1' %s
diff --git a/ext/dom/tests/DOMDocument_load_error5.phpt b/ext/dom/tests/DOMDocument_load_error5.phpt
new file mode 100644
index 0000000000..a374f9474d
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_error5.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::load() detects not-well formed XML
+--DESCRIPTION--
+This test verifies the method detects extra content at the end of the document
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/not_well_formed5.xml
+LOAD_OPTIONS=0
+EXPECTED_RESULT=0
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
diff --git a/ext/dom/tests/DOMDocument_load_variation1.phpt b/ext/dom/tests/DOMDocument_load_variation1.phpt
new file mode 100644
index 0000000000..b2b99e74c7
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_variation1.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Test DOMDocument::load() with LIBXML_DTDLOAD option
+--DESCRIPTION--
+This test verifies the right behaviour of the LIBXML_DTDLOAD constant
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDLOAD
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECT--
diff --git a/ext/dom/tests/DOMDocument_load_variation2.phpt b/ext/dom/tests/DOMDocument_load_variation2.phpt
new file mode 100644
index 0000000000..c8460e55eb
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_variation2.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::load() with LIBXML_DTDVALID option
+--DESCRIPTION--
+This test verifies the right behaviour of the LIBXML_DTDVALID constant
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/wrong_book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDVALID
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECTF--
+Warning: DOMDocument::load%r(XML){0,1}%r(): Element book content does not follow the DTD, expecting (title , author), got (title author author ) %s
diff --git a/ext/dom/tests/DOMDocument_load_variation3.phpt b/ext/dom/tests/DOMDocument_load_variation3.phpt
new file mode 100644
index 0000000000..77801d475e
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_variation3.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test DOMDocument::load() with LIBXML_DTDVALID and LIBXML_NOERROR options
+--DESCRIPTION--
+This test vrifies the right behaviour of the LIBXML_NOERROR constant
+which avoids the display of the warning message
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/wrong_book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDVALID | LIBXML_NOERROR
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentload_test_method.php
+--EXPECT--
diff --git a/ext/dom/tests/DOMDocument_load_variation4.phpt b/ext/dom/tests/DOMDocument_load_variation4.phpt
new file mode 100644
index 0000000000..3bf7ccc04d
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_load_variation4.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test DOMDocument::load() with LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT, LIBXML_NOBLANKS
+--DESCRIPTION--
+This test verifies the right behaviour of the following constants:
+LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT and LIBXML_NOBLANKS
+Environment variables used in the test:
+- XML_FILE: the xml file to load
+- LOAD_OPTIONS: the second parameter to pass to the method
+- EXPECTED_RESULT: the expected result
+--CREDITS--
+Antonio Diaz Ruiz <dejalatele@gmail.com>
+--INI--
+assert.bail=true
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--ENV--
+XML_FILE=/book_with_dtd.xml
+LOAD_OPTIONS=LIBXML_DTDATTR|LIBXML_NOCDATA|LIBXML_NOENT|LIBXML_NOBLANKS
+EXPECTED_RESULT=1
+--FILE_EXTERNAL--
+domdocumentload_test_method_savexml.php
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE books SYSTEM "books.dtd">
+<books><book><title default="default title">The Grapes of Wrath</title><author>John Steinbeck</author></book><book><title default="default title">The Pearl</title><author>John Steinbeck</author></book><book><title default="default title">entity is only for test purposes</title><author>data for test</author></book></books>
diff --git a/ext/dom/tests/book_with_dtd.xml b/ext/dom/tests/book_with_dtd.xml
new file mode 100644
index 0000000000..de12e92102
--- /dev/null
+++ b/ext/dom/tests/book_with_dtd.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE books SYSTEM "books.dtd">
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>&entitest;</title>
+ <author><![CDATA[data for test]]></author>
+ </book>
+</books>
diff --git a/ext/dom/tests/books.dtd b/ext/dom/tests/books.dtd
new file mode 100644
index 0000000000..b3f03c1c16
--- /dev/null
+++ b/ext/dom/tests/books.dtd
@@ -0,0 +1,7 @@
+<!ENTITY entitest "entity is only for test purposes">
+<!ATTLIST title
+ default CDATA "default title">
+ <!ELEMENT books (book*)>
+ <!ELEMENT book (title, author)>
+ <!ELEMENT title (#PCDATA)>
+ <!ELEMENT author (#PCDATA)>
diff --git a/ext/dom/tests/domdocumentload_test_method.php b/ext/dom/tests/domdocumentload_test_method.php
new file mode 100644
index 0000000000..7afce15c3a
--- /dev/null
+++ b/ext/dom/tests/domdocumentload_test_method.php
@@ -0,0 +1,12 @@
+<?php
+include(dirname(__FILE__) . '/domdocumentload_utilities.php');
+
+$doc = new DOMDocument();
+
+$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS'));
+
+$result = $doc->load(dirname(__FILE__) . getenv('XML_FILE'), $libxml_options);
+
+$expectedResult = (bool) getenv('EXPECTED_RESULT');
+assert('$result === $expectedResult');
+?>
diff --git a/ext/dom/tests/domdocumentload_test_method_savexml.php b/ext/dom/tests/domdocumentload_test_method_savexml.php
new file mode 100644
index 0000000000..8ffd944524
--- /dev/null
+++ b/ext/dom/tests/domdocumentload_test_method_savexml.php
@@ -0,0 +1,14 @@
+<?php
+include(dirname(__FILE__) . '/domdocumentload_utilities.php');
+
+$doc = new DOMDocument();
+
+$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS'));
+
+$result = $doc->load(dirname(__FILE__) . getenv('XML_FILE'), $libxml_options);
+
+$expectedResult = (bool) getenv('EXPECTED_RESULT');
+assert('$result === $expectedResult');
+
+echo $doc->saveXML();
+?>
diff --git a/ext/dom/tests/domdocumentload_utilities.php b/ext/dom/tests/domdocumentload_utilities.php
new file mode 100644
index 0000000000..efd1e5a1a5
--- /dev/null
+++ b/ext/dom/tests/domdocumentload_utilities.php
@@ -0,0 +1,16 @@
+<?php
+
+function libxml_options_to_int($libxmlOptions) {
+
+ $defined_constants = get_defined_constants(true);
+ $env_array = explode('|', $libxmlOptions);
+ $libxml_constants = array_intersect_key($defined_constants['libxml'], array_flip($env_array));
+
+ $sum = 0;
+ foreach($libxml_constants as $value) {
+ $sum = $sum|$value;
+ }
+
+ return $sum;
+}
+?>
diff --git a/ext/dom/tests/domdocumentloadxml_test_method.php b/ext/dom/tests/domdocumentloadxml_test_method.php
new file mode 100644
index 0000000000..7c4be85cf1
--- /dev/null
+++ b/ext/dom/tests/domdocumentloadxml_test_method.php
@@ -0,0 +1,12 @@
+<?php
+include(dirname(__FILE__) . '/domdocumentload_utilities.php');
+
+$doc = new DOMDocument();
+
+$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS'));
+$result = $doc->loadXML(file_get_contents(dirname(__FILE__) . getenv('XML_FILE')),
+ $libxml_options);
+
+$expectedResult = (bool) getenv('EXPECTED_RESULT');
+assert('$result === $expectedResult');
+?>
diff --git a/ext/dom/tests/domdocumentloadxml_test_method_savexml.php b/ext/dom/tests/domdocumentloadxml_test_method_savexml.php
new file mode 100644
index 0000000000..550219fb78
--- /dev/null
+++ b/ext/dom/tests/domdocumentloadxml_test_method_savexml.php
@@ -0,0 +1,14 @@
+<?php
+include(dirname(__FILE__) . '/domdocumentload_utilities.php');
+
+$doc = new DOMDocument();
+
+$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS'));
+$result = $doc->loadXML(file_get_contents(dirname(__FILE__) . getenv('XML_FILE')),
+ $libxml_options);
+
+$expectedResult = (bool) getenv('EXPECTED_RESULT');
+assert('$result === $expectedResult');
+
+echo $doc->saveXML();
+?>
diff --git a/ext/dom/tests/not_well_formed.xml b/ext/dom/tests/not_well_formed.xml
new file mode 100644
index 0000000000..d362e0c4b9
--- /dev/null
+++ b/ext/dom/tests/not_well_formed.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" ?>
+<!-- Opening and ending tag mismatch -->
+<books>
+ <book>
+ <title>The Grapes of Wrath
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/not_well_formed2.xml b/ext/dom/tests/not_well_formed2.xml
new file mode 100644
index 0000000000..da6b3bccba
--- /dev/null
+++ b/ext/dom/tests/not_well_formed2.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" ?>
+<!-- AttValue: " or ' expected -->
+<books>
+ <book number=nine>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/not_well_formed3.xml b/ext/dom/tests/not_well_formed3.xml
new file mode 100644
index 0000000000..99b2189074
--- /dev/null
+++ b/ext/dom/tests/not_well_formed3.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" ?>
+<!-- Opening and ending tag mismatch -->
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <boOk>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/not_well_formed4.xml b/ext/dom/tests/not_well_formed4.xml
new file mode 100644
index 0000000000..581b8bd962
--- /dev/null
+++ b/ext/dom/tests/not_well_formed4.xml
@@ -0,0 +1,12 @@
+<?xml version="3.1" ?>
+<!-- Unsupported version '3.1' -->
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/not_well_formed5.xml b/ext/dom/tests/not_well_formed5.xml
new file mode 100644
index 0000000000..f42ead83ab
--- /dev/null
+++ b/ext/dom/tests/not_well_formed5.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<!-- Extra content at the end of the document -->
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
diff --git a/ext/dom/tests/wrong_book_with_dtd.xml b/ext/dom/tests/wrong_book_with_dtd.xml
new file mode 100644
index 0000000000..3a2d48e355
--- /dev/null
+++ b/ext/dom/tests/wrong_book_with_dtd.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE books SYSTEM "books.dtd">
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ <author>John Steinbeck</author>
+ </book>
+ <book>
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>