Browse Source

Tests from PHP London TestFest 2008

PECL
Steve Seear 18 years ago
parent
commit
2b20e3d914
  1. 21
      ext/dom/tests/DOMComment_insertData_basic.phpt
  2. 24
      ext/dom/tests/DOMComment_insertData_error1.phpt
  3. 24
      ext/dom/tests/DOMComment_insertData_error2.phpt

21
ext/dom/tests/DOMComment_insertData_basic.phpt

@ -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-->

24
ext/dom/tests/DOMComment_insertData_error1.phpt

@ -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

24
ext/dom/tests/DOMComment_insertData_error2.phpt

@ -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
Loading…
Cancel
Save