Skip to content

Commit 24f3693

Browse files
dejalatelesmalyshev
authored andcommitted
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
1 parent 473d665 commit 24f3693

33 files changed

+628
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() basic behavior
3+
--DESCRIPTION--
4+
This test verifies the basic behaviour of the method
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/book.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=1
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECT--
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects an opening and ending tag mismatch
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: title line 5 and book %s
23+
24+
Warning: DOMDocument::load%r(XML){0,1}%r(): expected '>' %s
25+
26+
Warning: DOMDocument::load%r(XML){0,1}%r(): Premature end of data in tag books %s
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects attributes values not closed between " or '
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed2.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): AttValue: " or ' expected %s
23+
24+
Warning: DOMDocument::load%r(XML){0,1}%r(): attributes construct error %s
25+
26+
Warning: DOMDocument::load%r(XML){0,1}%r(): Couldn't find end of Start Tag book %s
27+
28+
Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: books %s
29+
30+
Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects a typo in tag names
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed3.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: boOk line 8 and book %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects an unsupported xml version
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed4.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Unsupported version '3.1' %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects extra content at the end of the document
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed5.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() with LIBXML_DTDLOAD option
3+
--DESCRIPTION--
4+
This test verifies the right behaviour of the LIBXML_DTDLOAD constant
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/book_with_dtd.xml
17+
LOAD_OPTIONS=LIBXML_DTDLOAD
18+
EXPECTED_RESULT=1
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECT--
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() with LIBXML_DTDVALID option
3+
--DESCRIPTION--
4+
This test verifies the right behaviour of the LIBXML_DTDVALID constant
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/wrong_book_with_dtd.xml
17+
LOAD_OPTIONS=LIBXML_DTDVALID
18+
EXPECTED_RESULT=1
19+
--FILE_EXTERNAL--
20+
domdocumentloadxml_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Element book content does not follow the DTD, expecting (title , author), got (title author author ) %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() with LIBXML_DTDVALID and LIBXML_NOERROR options
3+
--DESCRIPTION--
4+
This test vrifies the right behaviour of the LIBXML_NOERROR constant
5+
which avoids the display of the warning message
6+
Environment variables used in the test:
7+
- XML_FILE: the xml file to load
8+
- LOAD_OPTIONS: the second parameter to pass to the method
9+
- EXPECTED_RESULT: the expected result
10+
--CREDITS--
11+
Antonio Diaz Ruiz <[email protected]>
12+
--INI--
13+
assert.bail=true
14+
--SKIPIF--
15+
<?php include('skipif.inc'); ?>
16+
--ENV--
17+
XML_FILE=/wrong_book_with_dtd.xml
18+
LOAD_OPTIONS=LIBXML_DTDVALID | LIBXML_NOERROR
19+
EXPECTED_RESULT=1
20+
--FILE_EXTERNAL--
21+
domdocumentloadxml_test_method.php
22+
--EXPECT--
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Test DOMDocument::loadXML() with LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT, LIBXML_NOBLANKS
3+
--DESCRIPTION--
4+
This test verifies the right behaviour of the following constants:
5+
LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT and LIBXML_NOBLANKS
6+
Environment variables used in the test:
7+
- XML_FILE: the xml file to load
8+
- LOAD_OPTIONS: the second parameter to pass to the method
9+
- EXPECTED_RESULT: the expected result
10+
--CREDITS--
11+
Antonio Diaz Ruiz <[email protected]>
12+
--INI--
13+
assert.bail=true
14+
--SKIPIF--
15+
<?php include('skipif.inc'); ?>
16+
--ENV--
17+
XML_FILE=/book_with_dtd.xml
18+
LOAD_OPTIONS=LIBXML_DTDATTR|LIBXML_NOCDATA|LIBXML_NOENT|LIBXML_NOBLANKS
19+
EXPECTED_RESULT=1
20+
--FILE_EXTERNAL--
21+
domdocumentloadxml_test_method_savexml.php
22+
--EXPECT--
23+
<?xml version="1.0" encoding="UTF-8"?>
24+
<!DOCTYPE books SYSTEM "books.dtd">
25+
<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>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Test DOMDocument::load() basic behavior
3+
--DESCRIPTION--
4+
This test verifies the basic behaviour of the method
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/book.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=1
19+
--FILE_EXTERNAL--
20+
domdocumentload_test_method.php
21+
--EXPECT--
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Test DOMDocument::load() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects an opening and ending tag mismatch
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentload_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: title line 5 and book %s
23+
24+
Warning: DOMDocument::load%r(XML){0,1}%r(): expected '>' %s
25+
26+
Warning: DOMDocument::load%r(XML){0,1}%r(): Premature end of data in tag books %s
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Test DOMDocument::load() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects attributes values not closed between " or '
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed2.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentload_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): AttValue: " or ' expected %s
23+
24+
Warning: DOMDocument::load%r(XML){0,1}%r(): attributes construct error %s
25+
26+
Warning: DOMDocument::load%r(XML){0,1}%r(): Couldn't find end of Start Tag book %s
27+
28+
Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: books %s
29+
30+
Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::load() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects and opening and ending tag mismatch
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed3.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentload_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: boOk line 8 and book %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::load() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects an unsupported xml version
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed4.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentload_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Unsupported version '3.1' %s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test DOMDocument::load() detects not-well formed XML
3+
--DESCRIPTION--
4+
This test verifies the method detects extra content at the end of the document
5+
Environment variables used in the test:
6+
- XML_FILE: the xml file to load
7+
- LOAD_OPTIONS: the second parameter to pass to the method
8+
- EXPECTED_RESULT: the expected result
9+
--CREDITS--
10+
Antonio Diaz Ruiz <[email protected]>
11+
--INI--
12+
assert.bail=true
13+
--SKIPIF--
14+
<?php include('skipif.inc'); ?>
15+
--ENV--
16+
XML_FILE=/not_well_formed5.xml
17+
LOAD_OPTIONS=0
18+
EXPECTED_RESULT=0
19+
--FILE_EXTERNAL--
20+
domdocumentload_test_method.php
21+
--EXPECTF--
22+
Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s

0 commit comments

Comments
 (0)