From 32d7f82402c6fa35583f425199a6abf85a16f6b9 Mon Sep 17 00:00:00 2001 From: Antonio Diaz Ruiz Date: Fri, 14 Jun 2013 23:11:08 +0200 Subject: [PATCH 1/3] 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 --- ext/dom/tests/DOMDocument_loadXML_basic.phpt | 21 +++++++++++++ ext/dom/tests/DOMDocument_loadXML_error1.phpt | 26 ++++++++++++++++ ext/dom/tests/DOMDocument_loadXML_error2.phpt | 30 +++++++++++++++++++ ext/dom/tests/DOMDocument_loadXML_error3.phpt | 22 ++++++++++++++ ext/dom/tests/DOMDocument_loadXML_error4.phpt | 22 ++++++++++++++ ext/dom/tests/DOMDocument_loadXML_error5.phpt | 22 ++++++++++++++ .../tests/DOMDocument_loadXML_variation1.phpt | 21 +++++++++++++ .../tests/DOMDocument_loadXML_variation2.phpt | 22 ++++++++++++++ .../tests/DOMDocument_loadXML_variation3.phpt | 22 ++++++++++++++ .../tests/DOMDocument_loadXML_variation4.phpt | 25 ++++++++++++++++ ext/dom/tests/DOMDocument_load_basic.phpt | 21 +++++++++++++ ext/dom/tests/DOMDocument_load_error1.phpt | 26 ++++++++++++++++ ext/dom/tests/DOMDocument_load_error2.phpt | 30 +++++++++++++++++++ ext/dom/tests/DOMDocument_load_error3.phpt | 22 ++++++++++++++ ext/dom/tests/DOMDocument_load_error4.phpt | 22 ++++++++++++++ ext/dom/tests/DOMDocument_load_error5.phpt | 22 ++++++++++++++ .../tests/DOMDocument_load_variation1.phpt | 21 +++++++++++++ .../tests/DOMDocument_load_variation2.phpt | 22 ++++++++++++++ .../tests/DOMDocument_load_variation3.phpt | 22 ++++++++++++++ .../tests/DOMDocument_load_variation4.phpt | 25 ++++++++++++++++ ext/dom/tests/book_with_dtd.xml | 16 ++++++++++ ext/dom/tests/books.dtd | 7 +++++ ext/dom/tests/domdocumentload_test_method.php | 12 ++++++++ .../domdocumentload_test_method_savexml.php | 14 +++++++++ ext/dom/tests/domdocumentload_utilities.php | 16 ++++++++++ .../tests/domdocumentloadxml_test_method.php | 12 ++++++++ ...domdocumentloadxml_test_method_savexml.php | 14 +++++++++ ext/dom/tests/not_well_formed.xml | 12 ++++++++ ext/dom/tests/not_well_formed2.xml | 12 ++++++++ ext/dom/tests/not_well_formed3.xml | 12 ++++++++ ext/dom/tests/not_well_formed4.xml | 12 ++++++++ ext/dom/tests/not_well_formed5.xml | 10 +++++++ ext/dom/tests/wrong_book_with_dtd.xml | 13 ++++++++ 33 files changed, 628 insertions(+) create mode 100644 ext/dom/tests/DOMDocument_loadXML_basic.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_error1.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_error2.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_error3.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_error4.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_error5.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_variation1.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_variation2.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_variation3.phpt create mode 100644 ext/dom/tests/DOMDocument_loadXML_variation4.phpt create mode 100644 ext/dom/tests/DOMDocument_load_basic.phpt create mode 100644 ext/dom/tests/DOMDocument_load_error1.phpt create mode 100644 ext/dom/tests/DOMDocument_load_error2.phpt create mode 100644 ext/dom/tests/DOMDocument_load_error3.phpt create mode 100644 ext/dom/tests/DOMDocument_load_error4.phpt create mode 100644 ext/dom/tests/DOMDocument_load_error5.phpt create mode 100644 ext/dom/tests/DOMDocument_load_variation1.phpt create mode 100644 ext/dom/tests/DOMDocument_load_variation2.phpt create mode 100644 ext/dom/tests/DOMDocument_load_variation3.phpt create mode 100644 ext/dom/tests/DOMDocument_load_variation4.phpt create mode 100644 ext/dom/tests/book_with_dtd.xml create mode 100644 ext/dom/tests/books.dtd create mode 100644 ext/dom/tests/domdocumentload_test_method.php create mode 100644 ext/dom/tests/domdocumentload_test_method_savexml.php create mode 100644 ext/dom/tests/domdocumentload_utilities.php create mode 100644 ext/dom/tests/domdocumentloadxml_test_method.php create mode 100644 ext/dom/tests/domdocumentloadxml_test_method_savexml.php create mode 100644 ext/dom/tests/not_well_formed.xml create mode 100644 ext/dom/tests/not_well_formed2.xml create mode 100644 ext/dom/tests/not_well_formed3.xml create mode 100644 ext/dom/tests/not_well_formed4.xml create mode 100644 ext/dom/tests/not_well_formed5.xml create mode 100644 ext/dom/tests/wrong_book_with_dtd.xml diff --git a/ext/dom/tests/DOMDocument_loadXML_basic.phpt b/ext/dom/tests/DOMDocument_loadXML_basic.phpt new file mode 100644 index 0000000000000..569593c00758d --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..52d44ea291dae --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..6ac4193dafd40 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..07f7ca77383bc --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..e35d3dcea5c83 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..a4aa1858f58cc --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..eb5c693e42f3b --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..a1e6e80220e3c --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..8e61ec4dbcc5d --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..6adefa8414089 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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-- + + +The Grapes of WrathJohn SteinbeckThe PearlJohn Steinbeckentity is only for test purposesdata for test diff --git a/ext/dom/tests/DOMDocument_load_basic.phpt b/ext/dom/tests/DOMDocument_load_basic.phpt new file mode 100644 index 0000000000000..6d70ed4522206 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..2ac3f50979c64 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..23a5e4827d557 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..b9ac49c466707 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..ca9ed79a3e847 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..a374f9474d147 --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..b2b99e74c77ab --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..c8460e55eb2ea --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..77801d475e0bd --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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 0000000000000..3bf7ccc04d85c --- /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 +--INI-- +assert.bail=true +--SKIPIF-- + +--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-- + + +The Grapes of WrathJohn SteinbeckThe PearlJohn Steinbeckentity is only for test purposesdata for test diff --git a/ext/dom/tests/book_with_dtd.xml b/ext/dom/tests/book_with_dtd.xml new file mode 100644 index 0000000000000..de12e92102aa6 --- /dev/null +++ b/ext/dom/tests/book_with_dtd.xml @@ -0,0 +1,16 @@ + + + + + The Grapes of Wrath + John Steinbeck + + + The Pearl + John Steinbeck + + + &entitest; + + + diff --git a/ext/dom/tests/books.dtd b/ext/dom/tests/books.dtd new file mode 100644 index 0000000000000..b3f03c1c1635d --- /dev/null +++ b/ext/dom/tests/books.dtd @@ -0,0 +1,7 @@ + + + + + + diff --git a/ext/dom/tests/domdocumentload_test_method.php b/ext/dom/tests/domdocumentload_test_method.php new file mode 100644 index 0000000000000..7afce15c3a75a --- /dev/null +++ b/ext/dom/tests/domdocumentload_test_method.php @@ -0,0 +1,12 @@ +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 0000000000000..8ffd9445246df --- /dev/null +++ b/ext/dom/tests/domdocumentload_test_method_savexml.php @@ -0,0 +1,14 @@ +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 0000000000000..efd1e5a1a52bc --- /dev/null +++ b/ext/dom/tests/domdocumentload_utilities.php @@ -0,0 +1,16 @@ + diff --git a/ext/dom/tests/domdocumentloadxml_test_method.php b/ext/dom/tests/domdocumentloadxml_test_method.php new file mode 100644 index 0000000000000..7c4be85cf1f2f --- /dev/null +++ b/ext/dom/tests/domdocumentloadxml_test_method.php @@ -0,0 +1,12 @@ +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 0000000000000..550219fb78c52 --- /dev/null +++ b/ext/dom/tests/domdocumentloadxml_test_method_savexml.php @@ -0,0 +1,14 @@ +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 0000000000000..d362e0c4b94e0 --- /dev/null +++ b/ext/dom/tests/not_well_formed.xml @@ -0,0 +1,12 @@ + + + + + The Grapes of Wrath + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl + John Steinbeck + + diff --git a/ext/dom/tests/not_well_formed2.xml b/ext/dom/tests/not_well_formed2.xml new file mode 100644 index 0000000000000..da6b3bccbaf80 --- /dev/null +++ b/ext/dom/tests/not_well_formed2.xml @@ -0,0 +1,12 @@ + + + + + The Grapes of Wrath + John Steinbeck + + + The Pearl + John Steinbeck + + diff --git a/ext/dom/tests/not_well_formed3.xml b/ext/dom/tests/not_well_formed3.xml new file mode 100644 index 0000000000000..99b2189074651 --- /dev/null +++ b/ext/dom/tests/not_well_formed3.xml @@ -0,0 +1,12 @@ + + + + + The Grapes of Wrath + John Steinbeck + + + The Pearl + John Steinbeck + + diff --git a/ext/dom/tests/not_well_formed4.xml b/ext/dom/tests/not_well_formed4.xml new file mode 100644 index 0000000000000..581b8bd9625b6 --- /dev/null +++ b/ext/dom/tests/not_well_formed4.xml @@ -0,0 +1,12 @@ + + + + + The Grapes of Wrath + John Steinbeck + + + The Pearl + John Steinbeck + + diff --git a/ext/dom/tests/not_well_formed5.xml b/ext/dom/tests/not_well_formed5.xml new file mode 100644 index 0000000000000..f42ead83ab36a --- /dev/null +++ b/ext/dom/tests/not_well_formed5.xml @@ -0,0 +1,10 @@ + + + + The Grapes of Wrath + John Steinbeck + + + The Pearl + John Steinbeck + 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 0000000000000..3a2d48e355f85 --- /dev/null +++ b/ext/dom/tests/wrong_book_with_dtd.xml @@ -0,0 +1,13 @@ + + + + + The Grapes of Wrath + John Steinbeck + John Steinbeck + + + The Pearl + John Steinbeck + + From 492e55f3b7becff818348f225b06bd74a61ec6a5 Mon Sep 17 00:00:00 2001 From: Antonio Diaz Ruiz Date: Mon, 24 Jun 2013 22:39:27 +0200 Subject: [PATCH 2/3] Adds 2 new xml files which include the dtd path relative to the base directory for the php source code. It fixs the fail on the load of the dtd in the tests modified by this commit. --- .../tests/DOMDocument_loadXML_variation1.phpt | 2 +- .../tests/DOMDocument_loadXML_variation2.phpt | 2 +- .../tests/DOMDocument_loadXML_variation4.phpt | 4 ++-- ext/dom/tests/book_with_dtd2.xml | 16 ++++++++++++++++ ext/dom/tests/wrong_book_with_dtd2.xml | 13 +++++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 ext/dom/tests/book_with_dtd2.xml create mode 100644 ext/dom/tests/wrong_book_with_dtd2.xml diff --git a/ext/dom/tests/DOMDocument_loadXML_variation1.phpt b/ext/dom/tests/DOMDocument_loadXML_variation1.phpt index eb5c693e42f3b..558137526f27e 100644 --- a/ext/dom/tests/DOMDocument_loadXML_variation1.phpt +++ b/ext/dom/tests/DOMDocument_loadXML_variation1.phpt @@ -13,7 +13,7 @@ assert.bail=true --SKIPIF-- --ENV-- -XML_FILE=/book_with_dtd.xml +XML_FILE=/book_with_dtd2.xml LOAD_OPTIONS=LIBXML_DTDLOAD EXPECTED_RESULT=1 --FILE_EXTERNAL-- diff --git a/ext/dom/tests/DOMDocument_loadXML_variation2.phpt b/ext/dom/tests/DOMDocument_loadXML_variation2.phpt index a1e6e80220e3c..71f638efc142d 100644 --- a/ext/dom/tests/DOMDocument_loadXML_variation2.phpt +++ b/ext/dom/tests/DOMDocument_loadXML_variation2.phpt @@ -13,7 +13,7 @@ assert.bail=true --SKIPIF-- --ENV-- -XML_FILE=/wrong_book_with_dtd.xml +XML_FILE=/wrong_book_with_dtd2.xml LOAD_OPTIONS=LIBXML_DTDVALID EXPECTED_RESULT=1 --FILE_EXTERNAL-- diff --git a/ext/dom/tests/DOMDocument_loadXML_variation4.phpt b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt index 6adefa8414089..5960daac86585 100644 --- a/ext/dom/tests/DOMDocument_loadXML_variation4.phpt +++ b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt @@ -14,12 +14,12 @@ assert.bail=true --SKIPIF-- --ENV-- -XML_FILE=/book_with_dtd.xml +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-- - + The Grapes of WrathJohn SteinbeckThe PearlJohn Steinbeckentity is only for test purposesdata for test diff --git a/ext/dom/tests/book_with_dtd2.xml b/ext/dom/tests/book_with_dtd2.xml new file mode 100644 index 0000000000000..1b1478d02e4f4 --- /dev/null +++ b/ext/dom/tests/book_with_dtd2.xml @@ -0,0 +1,16 @@ + + + + + The Grapes of Wrath + John Steinbeck + + + The Pearl + John Steinbeck + + + &entitest; + + + 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 0000000000000..aad520f9b6b77 --- /dev/null +++ b/ext/dom/tests/wrong_book_with_dtd2.xml @@ -0,0 +1,13 @@ + + + + + The Grapes of Wrath + John Steinbeck + John Steinbeck + + + The Pearl + John Steinbeck + + From e654895eb80fd22538341169f6f1aac2de4acb2e Mon Sep 17 00:00:00 2001 From: Antonio Diaz Ruiz Date: Tue, 25 Jun 2013 22:09:38 +0200 Subject: [PATCH 3/3] Embeds the content of the DTD in the DOCTYPE declaration of the XML files. --- ext/dom/tests/DOMDocument_loadXML_variation4.phpt | 9 ++++++++- ext/dom/tests/book_with_dtd2.xml | 9 ++++++++- ext/dom/tests/wrong_book_with_dtd2.xml | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ext/dom/tests/DOMDocument_loadXML_variation4.phpt b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt index 5960daac86585..4f1ea37c1924f 100644 --- a/ext/dom/tests/DOMDocument_loadXML_variation4.phpt +++ b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt @@ -21,5 +21,12 @@ EXPECTED_RESULT=1 domdocumentloadxml_test_method_savexml.php --EXPECT-- - + + + + + + +]> The Grapes of WrathJohn SteinbeckThe PearlJohn Steinbeckentity is only for test purposesdata for test diff --git a/ext/dom/tests/book_with_dtd2.xml b/ext/dom/tests/book_with_dtd2.xml index 1b1478d02e4f4..aeb4f0b800d63 100644 --- a/ext/dom/tests/book_with_dtd2.xml +++ b/ext/dom/tests/book_with_dtd2.xml @@ -1,5 +1,12 @@ - + + + + + + +]> The Grapes of Wrath diff --git a/ext/dom/tests/wrong_book_with_dtd2.xml b/ext/dom/tests/wrong_book_with_dtd2.xml index aad520f9b6b77..6c49deb1f5697 100644 --- a/ext/dom/tests/wrong_book_with_dtd2.xml +++ b/ext/dom/tests/wrong_book_with_dtd2.xml @@ -1,5 +1,12 @@ - + + + + + + +]> The Grapes of Wrath