]> granicus.if.org Git - php/commitdiff
Tests from London test fest 2008
authorZoe Slattery <zoe@php.net>
Sat, 17 May 2008 13:26:51 +0000 (13:26 +0000)
committerZoe Slattery <zoe@php.net>
Sat, 17 May 2008 13:26:51 +0000 (13:26 +0000)
ext/dom/tests/DOMComment_replaceData_basic.phpt [new file with mode: 0644]
ext/dom/tests/DOMComment_replaceData_error1.phpt [new file with mode: 0644]
ext/dom/tests/DOMComment_replaceData_error2.phpt [new file with mode: 0644]

diff --git a/ext/dom/tests/DOMComment_replaceData_basic.phpt b/ext/dom/tests/DOMComment_replaceData_basic.phpt
new file mode 100644 (file)
index 0000000..10bf677
--- /dev/null
@@ -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 (file)
index 0000000..4ae4cb6
--- /dev/null
@@ -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 (file)
index 0000000..89614f9
--- /dev/null
@@ -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