diff options
-rw-r--r-- | ext/dom/tests/DOMComment_replaceData_basic.phpt | 29 | ||||
-rw-r--r-- | ext/dom/tests/DOMComment_replaceData_error1.phpt | 24 | ||||
-rw-r--r-- | ext/dom/tests/DOMComment_replaceData_error2.phpt | 24 |
3 files changed, 77 insertions, 0 deletions
diff --git a/ext/dom/tests/DOMComment_replaceData_basic.phpt b/ext/dom/tests/DOMComment_replaceData_basic.phpt new file mode 100644 index 0000000000..10bf677ff3 --- /dev/null +++ b/ext/dom/tests/DOMComment_replaceData_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test replacing data into a DOMComment basic test +--CREDITS-- +Andrew Larssen <al@larssen.org> +London TestFest 2008 +--SKIPIF-- +<?php // require_once('skipif.inc'); ?> +--FILE-- +<?php + +$dom = new DomDocument(); +$comment = $dom->createComment('test-comment'); +$comment->replaceData(4,1,'replaced'); +$dom->appendChild($comment); +echo $dom->saveXML(); + +// Replaces rest of string if count is greater than length of existing string +$dom = new DomDocument(); +$comment = $dom->createComment('test-comment'); +$comment->replaceData(0,50,'replaced'); +$dom->appendChild($comment); +echo $dom->saveXML(); + +?> +--EXPECTF-- +<?xml version="1.0"?> +<!--testreplacedcomment--> +<?xml version="1.0"?> +<!--replaced--> diff --git a/ext/dom/tests/DOMComment_replaceData_error1.phpt b/ext/dom/tests/DOMComment_replaceData_error1.phpt new file mode 100644 index 0000000000..4ae4cb61da --- /dev/null +++ b/ext/dom/tests/DOMComment_replaceData_error1.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test replacing data into a DOMComment basic test +--CREDITS-- +Andrew Larssen <al@larssen.org> +London TestFest 2008 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +//Negative offset +$dom = new DomDocument(); +$comment = $dom->createComment('test-comment'); +try { + $comment->replaceData(-1,4,'-inserted'); +} catch (DOMException $e ) { + if ($e->getMessage() == 'Index Size Error'){ + echo "Throws DOMException for -ve offest\n"; + } +} + +?> +--EXPECTF-- +Throws DOMException for -ve offest diff --git a/ext/dom/tests/DOMComment_replaceData_error2.phpt b/ext/dom/tests/DOMComment_replaceData_error2.phpt new file mode 100644 index 0000000000..89614f9756 --- /dev/null +++ b/ext/dom/tests/DOMComment_replaceData_error2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test replacing data into a DOMComment basic test +--CREDITS-- +Andrew Larssen <al@larssen.org> +London TestFest 2008 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +//offset to large +$dom = new DomDocument(); +$comment = $dom->createComment('test-comment'); +try { + $comment->replaceData(999,4,'-inserted'); +} catch (DOMException $e ) { + if ($e->getMessage() == 'Index Size Error'){ + echo "Throws DOMException for offest too large\n"; + } +} + +?> +--EXPECTF-- +Throws DOMException for offest too large
\ No newline at end of file |