]> granicus.if.org Git - php/commitdiff
Tests from PHP London TestFest 2008
authorSteve Seear <stevseea@php.net>
Mon, 19 May 2008 12:56:21 +0000 (12:56 +0000)
committerSteve Seear <stevseea@php.net>
Mon, 19 May 2008 12:56:21 +0000 (12:56 +0000)
ext/dom/tests/DOMComment_insertData_basic.phpt [new file with mode: 0644]
ext/dom/tests/DOMComment_insertData_error1.phpt [new file with mode: 0644]
ext/dom/tests/DOMComment_insertData_error2.phpt [new file with mode: 0644]

diff --git a/ext/dom/tests/DOMComment_insertData_basic.phpt b/ext/dom/tests/DOMComment_insertData_basic.phpt
new file mode 100644 (file)
index 0000000..5a4857d
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Test inserting data into a DOMComment basic test
+--CREDITS--
+Andrew Larssen <al@larssen.org>
+London TestFest 2008
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+//correct offset
+$dom = new DomDocument();
+$comment = $dom->createComment('test-comment');
+$comment->insertData(4,'-inserted');
+$dom->appendChild($comment);
+echo $dom->saveXML();
+
+?>
+--EXPECTF--
+<?xml version="1.0"?>
+<!--test-inserted-comment-->
diff --git a/ext/dom/tests/DOMComment_insertData_error1.phpt b/ext/dom/tests/DOMComment_insertData_error1.phpt
new file mode 100644 (file)
index 0000000..56922ac
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Test inserting 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->insertData(-1,'-inserted');
+} catch (DOMException $e ) {
+  if ($e->getMessage() == 'Index Size Error'){
+    echo "Throws DOMException for -ve offset\n";
+  }
+}
+
+?>
+--EXPECTF--
+Throws DOMException for -ve offset
diff --git a/ext/dom/tests/DOMComment_insertData_error2.phpt b/ext/dom/tests/DOMComment_insertData_error2.phpt
new file mode 100644 (file)
index 0000000..d2affa8
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Test inserting 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->insertData(999,'-inserted');
+} catch (DOMException $e ) {
+  if ($e->getMessage() == 'Index Size Error'){
+    echo "Throws DOMException for offset too large\n";
+  }
+}
+
+?>
+--EXPECTF--
+Throws DOMException for offset too large
\ No newline at end of file