diff options
author | Sean Finney <seanius@debian.org> | 2009-06-24 22:49:04 +0200 |
---|---|---|
committer | Sean Finney <seanius@debian.org> | 2009-06-24 22:49:04 +0200 |
commit | 84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (patch) | |
tree | 9829bd578af8a4a8b42b04277f9067e00dc5ad90 /ext/dom | |
parent | 6821b67124604da690c5e9276d5370d679c63ac8 (diff) | |
download | php-upstream/5.3.0_RC4.tar.gz |
Imported Upstream version 5.3.0~RC4upstream/5.3.0_RC4upstream/5.3.0.RC4
Diffstat (limited to 'ext/dom')
33 files changed, 580 insertions, 8 deletions
diff --git a/ext/dom/document.c b/ext/dom/document.c index 5cd0a7e82..ea3d1a825 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: document.c,v 1.68.2.3.2.5.2.15 2009/03/13 13:43:29 rrichards Exp $ */ +/* $Id: document.c,v 1.68.2.3.2.5.2.17 2009/06/14 13:13:35 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1196,6 +1196,9 @@ PHP_FUNCTION(dom_document_import_node) if (nodep->doc == docp) { retnodep = nodep; } else { + if ((recursive == 0) && (nodep->type == XML_ELEMENT_NODE)) { + recursive = 2; + } retnodep = xmlDocCopyNode(nodep, docp, recursive); if (!retnodep) { RETURN_FALSE; @@ -1933,11 +1936,7 @@ PHP_FUNCTION(dom_document_validate) } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); - - if (docp->intSubset == NULL) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No DTD given in XML-Document"); - } - + cvp = xmlNewValidCtxt(); cvp->userData = NULL; diff --git a/ext/dom/tests/DOMAttr_construct_error_001.phpt b/ext/dom/tests/DOMAttr_construct_error_001.phpt new file mode 100644 index 000000000..08734ca47 --- /dev/null +++ b/ext/dom/tests/DOMAttr_construct_error_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +DOMAttr __construct() with no arguments. +--CREDITS-- +Josh Sweeney <jsweeney@alt-invest.net> +# TestFest Atlanta 2009-05-14 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$attr = new DOMAttr(); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'DOMException' with message 'DOMAttr::__construct() expects at least 1 parameter, 0 given' in %s:%d +Stack trace: +#0 %s(%d): DOMAttr->__construct() +#1 {main} + thrown in %s on line %d diff --git a/ext/dom/tests/DOMAttr_name_basic_001.phpt b/ext/dom/tests/DOMAttr_name_basic_001.phpt new file mode 100644 index 000000000..29ca8c585 --- /dev/null +++ b/ext/dom/tests/DOMAttr_name_basic_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMAttr read $name property. +--CREDITS-- +Nic Rosental <nicrosental@gmail.com> +# TestFest Atlanta 2009-05-14 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$attr = new DOMAttr('category', 'books'); +print $attr->name; +?> +--EXPECT-- +category
\ No newline at end of file diff --git a/ext/dom/tests/DOMAttr_ownerElement_error_001.phpt b/ext/dom/tests/DOMAttr_ownerElement_error_001.phpt new file mode 100755 index 000000000..a7766541d --- /dev/null +++ b/ext/dom/tests/DOMAttr_ownerElement_error_001.phpt @@ -0,0 +1,23 @@ +--TEST-- +Read $ownerElement with null parent. +--CREDITS-- +Travis Pew +# TestFest Atlanta 2009-05-14 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); +$attr = $root->setAttribute('category', 'books'); +$document->removeChild($root); +$root = null; +var_dump($attr->ownerElement); +?> +--EXPECTF-- +Warning: Couldn't fetch DOMAttr. Node no longer exists in %s on line %d + +Notice: Undefined property: DOMAttr::$ownerElement in %s on line %d +NULL diff --git a/ext/dom/tests/DOMAttr_value_basic_002.phpt b/ext/dom/tests/DOMAttr_value_basic_002.phpt new file mode 100644 index 000000000..cf71eebf3 --- /dev/null +++ b/ext/dom/tests/DOMAttr_value_basic_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +Write non-string $value property +--CREDIT-- +Eric Berg <ehberg@gmail.com> +# TestFest Atlanta 2009-05-14 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$attr = new DOMAttr('category'); +$attr->value = 1; +print $attr->value; +?> +--EXPECTF-- +1
\ No newline at end of file diff --git a/ext/dom/tests/DOMCDATASection_construct_error_001.phpt b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt new file mode 100644 index 000000000..4db2130ba --- /dev/null +++ b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt @@ -0,0 +1,21 @@ +--TEST-- +__construct() with no arguments. +--CREDITS-- +Nic Rosental nicrosental@gmail.com +# TestFest Atlanta 2009-5-14 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + try + { + $section = new DOMCDataSection(); + + } + catch (Exception $e) + { + echo $e->getMessage(); + } +?> +--EXPECT-- +DOMCdataSection::__construct() expects exactly 1 parameter, 0 given
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_appendData_error_001.phpt b/ext/dom/tests/DOMCharacterData_appendData_error_001.phpt new file mode 100644 index 000000000..4126f9914 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_appendData_error_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMCharacterData::appendData() with no arguments. +--CREDITS-- +Eric Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('test'); +$root->appendChild($cdata); +$cdata->appendData(); +?> +--EXPECTF-- +Warning: DOMCharacterData::appendData() expects exactly 1 parameter, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_data_error_002.phpt b/ext/dom/tests/DOMCharacterData_data_error_002.phpt new file mode 100755 index 000000000..9dae096e6 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_data_error_002.phpt @@ -0,0 +1,14 @@ +--TEST-- +Invalid State Error when getting data on DOMCharacterData out of content. +--CREDIT-- +Eric Berg <ehberg@gmail.com> +# TestFest Atlanta 2009-05-14 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$character_data = new DOMCharacterData(); +print $character_data->data; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt b/ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt new file mode 100644 index 000000000..ad104f1ee --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_deleteData_basic_001.phpt @@ -0,0 +1,20 @@ +--TEST-- +DOMCharacterData::deleteData() with count exceeding string size. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('test'); +$root->appendChild($cdata); +$cdata->deleteData(1, 10); +var_dump($cdata->data); +?> +--EXPECTF-- +%unicode|string%(%d) "t"
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt b/ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt new file mode 100644 index 000000000..3fa7fba2d --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_deleteData_error_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMCharacterData::deleteData() with no arguments. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('test'); +$root->appendChild($cdata); +$cdata->deleteData(); +?> +--EXPECTF-- +Warning: DOMCharacterData::deleteData() expects exactly 2 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt b/ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt new file mode 100644 index 000000000..117d5de24 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_deleteData_error_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +DOMCharacterData::deleteData() with offset exceeding string size. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('test'); +$root->appendChild($cdata); +$cdata->deleteData(5, 1); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'DOMException' with message 'Index Size Error' in %s:%d +Stack trace: +#0 %s(%d): DOMCharacterData->deleteData(5, 1) +#1 {main} + thrown in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_insertData_error_001.phpt b/ext/dom/tests/DOMCharacterData_insertData_error_001.phpt new file mode 100644 index 000000000..813a0be52 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_insertData_error_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMCharacterData::insertData() with no arguments. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('test'); +$root->appendChild($cdata); +$cdata->insertData(); +?> +--EXPECTF-- +Warning: DOMCharacterData::insertData() expects exactly 2 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt b/ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt new file mode 100644 index 000000000..45d25dd85 --- /dev/null +++ b/ext/dom/tests/DOMCharacterData_replaceData_error_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMCharacterData::replaceData() with no arguments. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$cdata = $document->createCDATASection('test'); +$root->appendChild($cdata); +$cdata->replaceData(); +?> +--EXPECTF-- +Warning: DOMCharacterData::replaceData() expects exactly 3 parameters, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMComment_construct_basic_001.phpt b/ext/dom/tests/DOMComment_construct_basic_001.phpt new file mode 100644 index 000000000..902f7bb57 --- /dev/null +++ b/ext/dom/tests/DOMComment_construct_basic_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMComment::__construct() with constructor called twice. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$dom = new DOMDocument('1.0', 'UTF-8'); +$element = $dom->appendChild(new DOMElement('root')); +$comment = new DOMComment("This is the first comment."); +$comment->__construct("This is the second comment."); +$comment = $element->appendChild($comment); +print $dom->saveXML(); +?> +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<root><!--This is the second comment.--></root> diff --git a/ext/dom/tests/DOMComment_construct_error_001.phpt b/ext/dom/tests/DOMComment_construct_error_001.phpt new file mode 100644 index 000000000..89142fe6f --- /dev/null +++ b/ext/dom/tests/DOMComment_construct_error_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +DOMComment::__construct() with more arguments than acceptable. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$comment = new DOMComment("comment1", "comment2"); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'DOMException' with message 'DOMComment::__construct() expects at most 1 parameter, 2 given' in %s:%d +Stack trace: +#0 %s(%d): DOMComment->__construct('comment1', 'comment2') +#1 {main} + thrown in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt new file mode 100644 index 000000000..a6f381be0 --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_appendXML_basic_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +DOMDocumentFragment::appendXML() with children with properties. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$fragment = $document->createDocumentFragment(); +$fragment->appendXML('<foo id="baz">bar</foo>'); +$root->appendChild($fragment); + +print $document->saveXML(); +?> +--EXPECT-- +<?xml version="1.0"?> +<root><foo id="baz">bar</foo></root> diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt new file mode 100644 index 000000000..6ffe510b0 --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_appendXML_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentFragment::appendXML() with no arguments. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fragment = new DOMDocumentFragment(); +$fragment->appendXML(); +?> +--EXPECTF-- +Warning: DOMDocumentFragment::appendXML() expects exactly 1 parameter, 0 given in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt new file mode 100644 index 000000000..c02c92084 --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_appendXML_error_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMDocumentFragment::appendXML() with unbound fragment. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fragment = new DOMDocumentFragment(); +$fragment->appendXML('<bait>crankbait</bait>'); +$document->appendChild($fragment); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'DOMException' with message 'No Modification Allowed Error' in %s:%d +Stack trace: +#0 %s(%d): DOMDocumentFragment->appendXML('<bait>crankbait...') +#1 {main} + thrown in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt b/ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt new file mode 100644 index 000000000..8735ae6ec --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_appendXML_error_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMDocumentFragment::appendXML() with unbalanced chunks. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$document = new DOMDocument; +$root = $document->createElement('root'); +$document->appendChild($root); + +$fragment = $document->createDocumentFragment(); +@$fragment->appendXML('<foo>is<bar>great</foo>'); +$root->appendChild($fragment); +?> +--EXPECTF-- +Warning: DOMNode::appendChild(): Document Fragment is empty in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt b/ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt new file mode 100644 index 000000000..6021bac0b --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_construct_basic_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +DOMDocumentFragment::__construct(). +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fragment = new DOMDocumentFragment(); +var_dump($fragment); +?> +--EXPECTF-- +object(DOMDocumentFragment)#%d (%d) { +} diff --git a/ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt b/ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt new file mode 100644 index 000000000..0d734452e --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_construct_basic_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +DOMDocumentFragment::__construct() called twice. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fragment = new DOMDocumentFragment(); +$fragment->__construct(); +var_dump($fragment); +?> +--EXPECTF-- +object(DOMDocumentFragment)#%d (%d) { +} diff --git a/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt b/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt new file mode 100644 index 000000000..91173c4b7 --- /dev/null +++ b/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +DOMDocumentFragment::__construct() with too many errors. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-24 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fragment = new DOMDocumentFragment("root"); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'DOMException' with message 'DOMDocumentFragment::__construct() expects exactly 0 parameters, 1 given' in %s:%d +Stack trace: +#0 %s(%d): DOMDocumentFragment->__construct('root') +#1 {main} + thrown in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_basic_001.phpt b/ext/dom/tests/DOMDocumentType_basic_001.phpt new file mode 100644 index 000000000..8991ed97d --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_basic_001.phpt @@ -0,0 +1,48 @@ +--TEST-- +DOMDocumentType: basic access to all properties. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +// Access publicId, systemId, name, internalSubset all with values. +$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; +$xml .= '<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML//EN" "docbookx.dtd">'; +$xml .= '<chapter>1</chapter>'; +$doc = new DOMDocument(); +$doc->loadXML($xml); +$doctype = $doc->doctype; +print "publicId: ".$doctype->publicId."\n"; +print "systemId: ".$doctype->systemId."\n"; +print "name: ".$doctype->name."\n"; +print "internalSubset: ".$doctype->internalSubset."\n"; + + +// Access entities and notations with values. +$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; +$xml .= '<!DOCTYPE img ['; +$xml .= ' <!ELEMENT img EMPTY>'; +$xml .= ' <!ATTLIST img src ENTITY #REQUIRED>'; +$xml .= ' <!ENTITY logo SYSTEM "http://www.xmlwriter.net/logo.gif" NDATA gif>'; +$xml .= ' <!NOTATION gif PUBLIC "gif viewer">'; +$xml .= ']>'; +$xml .= '<img src="logo"/>'; +$doc = new DOMDocument(); +$doc->loadXML($xml); +$doctype = $doc->doctype; +$entities = $doctype->entities; +$entity = $entities->item(0); +print 'entity: '.$entity->nodeName."\n"; +$notations = $doctype->notations; +$notation = $notations->item(0); +print 'notation: '.$notation->nodeName."\n"; +?> +--EXPECT-- +publicId: -//OASIS//DTD DocBook XML//EN +systemId: docbookx.dtd +name: chapter +internalSubset: <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML//EN" "docbookx.dtd"> +entity: logo +notation: gif
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_entities_error_001.phpt b/ext/dom/tests/DOMDocumentType_entities_error_001.phpt new file mode 100644 index 000000000..73655b06d --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_entities_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentType::entities with invalid state. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$doctype = new DOMDocumentType(); +$entities = $doctype->entities; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt b/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt new file mode 100644 index 000000000..c1f7d9b4d --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_internalSubset_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentType::internalSubset with invalid state. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$doctype = new DOMDocumentType(); +$internalSubset = $doctype->internalSubset; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_name_error_001.phpt b/ext/dom/tests/DOMDocumentType_name_error_001.phpt new file mode 100644 index 000000000..d2426e88f --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_name_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentType::name with invalid state. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$doctype = new DOMDocumentType(); +$name = $doctype->name; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_notations_error_001.phpt b/ext/dom/tests/DOMDocumentType_notations_error_001.phpt new file mode 100644 index 000000000..e4d1c3c8e --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_notations_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentType::notations with invalid state. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$doctype = new DOMDocumentType(); +$notations = $doctype->notations; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt b/ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt new file mode 100644 index 000000000..49a7eecbf --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_publicId_basic_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMDocumentType::publicId with empty value. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; +$xml .= '<!DOCTYPE chapter SYSTEM "http://www.xmlwriter.net/logo.gif">'; +$xml .= '<chapter>1</chapter>'; +$doc = new DOMDocument(); +$doc->loadXML($xml); +$doctype = $doc->doctype; +var_dump($doctype->publicId); +?> +--EXPECT-- +string(0) ""
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt b/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt new file mode 100644 index 000000000..275bb65e3 --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_publicId_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentType::publicId with invalid state. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$doctype = new DOMDocumentType(); +$publicId = $doctype->publicId; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt b/ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt new file mode 100644 index 000000000..56f7ddda9 --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_systemId_basic_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +DOMDocumentType::systemId with empty value. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$xml = '<?xml version="1.0" encoding="UTF-8" ?>'; +$xml .= '<!DOCTYPE chapter>'; +$xml .= '<chapter>1</chapter>'; +$doc = new DOMDocument(); +$doc->loadXML($xml); +$doctype = $doc->doctype; +var_dump($doctype->systemId); +?> +--EXPECT-- +string(0) ""
\ No newline at end of file diff --git a/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt b/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt new file mode 100644 index 000000000..a4aadd707 --- /dev/null +++ b/ext/dom/tests/DOMDocumentType_systemId_error_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +DOMDocumentType::systemId with invalid state. +--CREDITS-- +Eric Lee Stewart <ericleestewart@gmail.com> +# TestFest Atlanta 2009-05-25 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$doctype = new DOMDocumentType(); +$systemId = $doctype->systemId; +?> +--EXPECTF-- +Warning: main(): Invalid State Error in %s on line %d
\ No newline at end of file diff --git a/ext/dom/tests/bug47849.phpt b/ext/dom/tests/bug47849.phpt new file mode 100644 index 000000000..7e6b02c8c --- /dev/null +++ b/ext/dom/tests/bug47849.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #47849 (Non-deep import loses the namespace). +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$aDOM= new DOMDocument(); +$aDOM->appendChild($aDOM->createElementNS('urn::root','r:root')); + +$fromdom= new DOMDocument(); +$fromdom->loadXML('<data xmlns="urn::data">aaa</data>'); + +$data= $fromdom->documentElement; +$aDOM->documentElement->appendChild($aDOM->importNode($data)); + +echo $aDOM->saveXML(); + +?> +--EXPECT-- +<?xml version="1.0"?> +<r:root xmlns:r="urn::root"><data xmlns="urn::data"/></r:root> diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 8bc12fd45..38d23da94 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xpath.c,v 1.26.2.1.2.1.2.12 2008/12/31 11:15:36 sebastian Exp $ */ +/* $Id: xpath.c,v 1.26.2.1.2.1.2.13 2009/06/06 02:40:48 mattwil Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -232,7 +232,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, } else if (retval->type == IS_BOOL) { valuePush(ctxt, xmlXPathNewBoolean(retval->value.lval)); } else if (retval->type == IS_OBJECT) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object can not be converted to a XPath-string"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object cannot be converted to a XPath-string"); valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); } else { convert_to_string_ex(&retval); |