forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP tests to check the DOM_NOT_FOUND error message is properly raised…
… by the DOMNode::insertBefore method
- Loading branch information
1 parent
2792855
commit a67ce30
Showing
5 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
--INI-- | ||
assert.bail=true | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$dom = new DOMDocument(); | ||
|
||
$doc = $dom->load("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('$doc !== 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
--INI-- | ||
assert.bail=true | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$dom = new DOMDocument(); | ||
|
||
$doc = $dom->load("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('$doc !== 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
--INI-- | ||
assert.bail=true | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$dom = new DOMDocument(); | ||
|
||
$doc = $dom->load("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('$doc !== 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
--INI-- | ||
assert.bail=true | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$dom = new DOMDocument(); | ||
|
||
$doc = $dom->load("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('$doc !== 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
--INI-- | ||
assert.bail=true | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$dom = new DOMDocument(); | ||
|
||
$doc = $dom->load("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('$doc !== false'); | ||
|
||
try { | ||
$parent_node->insertBefore($new_node, $ref_node); | ||
} catch(DOMException $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
Not Found Error |