summaryrefslogtreecommitdiff
path: root/ext/dom/tests
diff options
context:
space:
mode:
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.phpt32
-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/DOMDocument_schemaValidateSource_addAttrs.phpt25
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt2
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt25
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt23
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_error4.phpt2
-rw-r--r--ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt23
-rw-r--r--ext/dom/tests/book-attr.xml11
-rwxr-xr-xext/dom/tests/book.xsd1
-rw-r--r--ext/dom/tests/book_with_dtd.xml16
-rw-r--r--ext/dom/tests/book_with_dtd2.xml23
-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
-rw-r--r--ext/dom/tests/wrong_book_with_dtd2.xml20
43 files changed, 788 insertions, 2 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..558137526f
--- /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_dtd2.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..71f638efc1
--- /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_dtd2.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..4f1ea37c19
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt
@@ -0,0 +1,32 @@
+--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_dtd2.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 [
+<!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)>
+]>
+<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/DOMDocument_schemaValidateSource_addAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_addAttrs.phpt
new file mode 100644
index 0000000000..994b94d0c8
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_addAttrs.phpt
@@ -0,0 +1,25 @@
+--TEST--
+DomDocument::schemaValidateSource() - Add missing attribute default values from schema
+--CREDITS--
+Chris Wright <info@daverandom.com>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book-attr.xml");
+
+$xsd = file_get_contents(dirname(__FILE__)."/book.xsd");
+
+$doc->schemaValidateSource($xsd, LIBXML_SCHEMA_CREATE);
+
+foreach ($doc->getElementsByTagName('book') as $book) {
+ var_dump($book->getAttribute('is-hardback'));
+}
+
+?>
+--EXPECT--
+string(5) "false"
+string(4) "true"
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt
index 65c8d8678f..f841b87428 100644
--- a/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt
@@ -17,5 +17,5 @@ var_dump($result);
?>
--EXPECTF--
-Warning: DOMDocument::schemaValidateSource() expects exactly 1 parameter, 0 given in %s.php on line %d
+Warning: DOMDocument::schemaValidateSource() expects at least 1 parameter, 0 given in %s.php on line %d
NULL
diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt
new file mode 100644
index 0000000000..7c98a74b1d
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt
@@ -0,0 +1,25 @@
+--TEST--
+DomDocument::schemaValidateSource() - Don't add missing attribute default values from schema
+--CREDITS--
+Chris Wright <info@daverandom.com>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book-attr.xml");
+
+$xsd = file_get_contents(dirname(__FILE__)."/book.xsd");
+
+$doc->schemaValidateSource($xsd);
+
+foreach ($doc->getElementsByTagName('book') as $book) {
+ var_dump($book->getAttribute('is-hardback'));
+}
+
+?>
+--EXPECT--
+string(0) ""
+string(4) "true"
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt
new file mode 100644
index 0000000000..e0b5251b23
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DomDocument::schemaValidate() - Add missing attribute default values from schema
+--CREDITS--
+Chris Wright <info@daverandom.com>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book-attr.xml");
+
+$doc->schemaValidate(dirname(__FILE__)."/book.xsd", LIBXML_SCHEMA_CREATE);
+
+foreach ($doc->getElementsByTagName('book') as $book) {
+ var_dump($book->getAttribute('is-hardback'));
+}
+
+?>
+--EXPECT--
+string(5) "false"
+string(4) "true"
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt
index d4817deca0..9e4b6c4b7c 100644
--- a/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt
+++ b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt
@@ -17,5 +17,5 @@ var_dump($result);
?>
--EXPECTF--
-Warning: DOMDocument::schemaValidate() expects exactly 1 parameter, 0 given in %s.php on line %d
+Warning: DOMDocument::schemaValidate() expects at least 1 parameter, 0 given in %s.php on line %d
NULL
diff --git a/ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt
new file mode 100644
index 0000000000..d253ad9690
--- /dev/null
+++ b/ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DomDocument::schemaValidate() - Don't add missing attribute default values from schema
+--CREDITS--
+Chris Wright <info@daverandom.com>
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument;
+
+$doc->load(dirname(__FILE__)."/book-attr.xml");
+
+$doc->schemaValidate(dirname(__FILE__)."/book.xsd");
+
+foreach ($doc->getElementsByTagName('book') as $book) {
+ var_dump($book->getAttribute('is-hardback'));
+}
+
+?>
+--EXPECT--
+string(0) ""
+string(4) "true"
diff --git a/ext/dom/tests/book-attr.xml b/ext/dom/tests/book-attr.xml
new file mode 100644
index 0000000000..ba4298d098
--- /dev/null
+++ b/ext/dom/tests/book-attr.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<books>
+ <book>
+ <title>The Grapes of Wrath</title>
+ <author>John Steinbeck</author>
+ </book>
+ <book is-hardback="true">
+ <title>The Pearl</title>
+ <author>John Steinbeck</author>
+ </book>
+</books>
diff --git a/ext/dom/tests/book.xsd b/ext/dom/tests/book.xsd
index 45986fc4b3..6b4a8ea545 100755
--- a/ext/dom/tests/book.xsd
+++ b/ext/dom/tests/book.xsd
@@ -9,6 +9,7 @@
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
</xs:sequence>
+ <xs:attribute name="is-hardback" type="xs:boolean" default="false" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
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/book_with_dtd2.xml b/ext/dom/tests/book_with_dtd2.xml
new file mode 100644
index 0000000000..aeb4f0b800
--- /dev/null
+++ b/ext/dom/tests/book_with_dtd2.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE books [
+<!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)>
+]>
+<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>
diff --git a/ext/dom/tests/wrong_book_with_dtd2.xml b/ext/dom/tests/wrong_book_with_dtd2.xml
new file mode 100644
index 0000000000..6c49deb1f5
--- /dev/null
+++ b/ext/dom/tests/wrong_book_with_dtd2.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE books [
+<!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)>
+]>
+<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>