Merge branch 'PHP-5.4' into PHP-5.5

This commit is contained in:
Xinchen Hui 2013-04-21 11:09:18 +08:00
commit 6b1928ba0b
6 changed files with 191 additions and 1 deletions

View File

@ -13,7 +13,7 @@ require_once('skipif.inc');
require_once('dom_test.inc'); require_once('dom_test.inc');
chdir(__DIR__); chdir(__DIR__);
$XMLStringGood = file_get_contents('note.xml'); $XMLStringGood = file_get_contents(dirname(__FILE__).'/note.xml');
$dom = new DOMDocument; $dom = new DOMDocument;
$dom->resolveExternals = TRUE; $dom->resolveExternals = TRUE;

View File

@ -0,0 +1,38 @@
--TEST--
Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised
--DESCRIPTION--
DOMNode::insertBefore(newNode, [refNode])
DOM_NOT_FOUND is raised if refnode is not a child
This test checks the error message is raised when the refnode is a sibling
--CREDITS--
Antonio Diaz Ruiz <dejalatele@gmail.com>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$dom = new DOMDocument();
$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS);
assert('$doc === true');
$parent_node = $dom->getElementsByTagName("book")->item(0);
assert('!is_null($parent_node)');
$new_node = $dom->createElement('newnode');
assert('$new_node !== false');
// getting a sibling as reference node to insert
$ref_node = $dom->getElementsByTagName("book")->item(1);
try {
$parent_node->insertBefore($new_node, $ref_node);
} catch(DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Not Found Error

View File

@ -0,0 +1,39 @@
--TEST--
Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised
--DESCRIPTION--
DOMNode::insertBefore(newNode, [refNode])
DOM_NOT_FOUND is raised if refnode is not a child
This test checks the error message is raised when refnode is the parent node
--CREDITS--
Antonio Diaz Ruiz <dejalatele@gmail.com>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$dom = new DOMDocument();
$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS);
assert('$doc === true');
$parent_node = $dom->getElementsByTagName("book")->item(0);
assert('!is_null($parent_node)');
$new_node = $dom->createElement('newnode');
assert('$new_node !== false');
// getting the parent node as reference node to insert
$ref_node = $dom->getElementsByTagName("book")->item(0)->parentNode;
assert('!is_null($ref_node)');
try {
$parent_node->insertBefore($new_node, $ref_node);
} catch(DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Not Found Error

View File

@ -0,0 +1,38 @@
--TEST--
Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised
--DESCRIPTION--
DOMNode::insertBefore(newNode, [refNode])
DOM_NOT_FOUND is raised if refnode is not a child
This test checks the error message is raised when the refnode is a brand new node
--CREDITS--
Antonio Diaz Ruiz <dejalatele@gmail.com>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$dom = new DOMDocument();
$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS);
assert('$doc === true');
$parent_node = $dom->getElementsByTagName("book")->item(0);
assert('!is_null($parent_node)');
$new_node = $dom->createElement('newnode');
assert('$new_node !== false');
// could be a brand new node
$ref_node = $dom->createElement('newnode2');
try {
$parent_node->insertBefore($new_node, $ref_node);
} catch(DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Not Found Error

View File

@ -0,0 +1,40 @@
--TEST--
Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised
--DESCRIPTION--
DOMNode::insertBefore(newNode, [refNode])
DOM_NOT_FOUND is raised if refnode is not a child
This test checks the error message is raised when the refnode is a descendant but not a child
--CREDITS--
Antonio Diaz Ruiz <dejalatele@gmail.com>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$dom = new DOMDocument();
$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS);
assert('$doc === true');
$parent_node = $dom->getElementsByTagName("book")->item(0);
assert('!is_null($parent_node)');
$new_node = $dom->createElement('newnode');
assert('$new_node !== false');
// creating a new node (descendant) and getting it as the refnode
$ref_node = $dom->createElement('newnode3');
$parent_node->childNodes->item(0)->appendChild($ref_node);
$dom->saveXML();
try {
$parent_node->insertBefore($new_node, $ref_node);
} catch(DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Not Found Error

View File

@ -0,0 +1,35 @@
--TEST--
Test DOMNode::insertBefore() check the error code DOM_NOT_FOUND is raised
--DESCRIPTION--
DOMNode::insertBefore(newNode, [refNode])
DOM_NOT_FOUND is raised if refnode is not a child
This test checks the error message is raised when the refnode is the parent
--CREDITS--
Antonio Diaz Ruiz <dejalatele@gmail.com>
--INI--
assert.bail=true
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
$dom = new DOMDocument();
$doc = $dom->load(dirname(__FILE__) . "/book.xml", LIBXML_NOBLANKS);
assert('$doc === true');
$parent_node = $dom->getElementsByTagName("book")->item(0);
assert('!is_null($parent_node)');
$ref_node = $parent_node;
$new_node = $dom->createElement('newnode');
assert('$new_node !== false');
try {
$parent_node->insertBefore($new_node, $ref_node);
} catch(DOMException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Not Found Error