From: Zoe Slattery Date: Thu, 15 May 2008 12:23:47 +0000 (+0000) Subject: Tests from London test fest 2008 X-Git-Tag: BEFORE_NEW_PARAMETER_PARSE~219 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=229bcbdfc69b5aa8f9ba5e5d02c3286d9d7fde01;p=php Tests from London test fest 2008 --- diff --git a/ext/dom/DOMDocument_createAttribute_basic.phpt b/ext/dom/DOMDocument_createAttribute_basic.phpt new file mode 100644 index 0000000000..5205a3e30f --- /dev/null +++ b/ext/dom/DOMDocument_createAttribute_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +DomDocument::createAttribute() - basic test for DomDocument::createAttribute() +--CREDITS-- +Muhammad Khalid Adnan +# TestFest 2008 +--FILE-- +createElement("para"); +$newnode = $doc->appendChild($node); + +// A pass case. +$test_attribute = $doc->createAttribute("hahaha"); +$node->appendChild($test_attribute); + +echo $doc->saveXML(); + +?> +--EXPECT-- + + + diff --git a/ext/dom/DOMDocument_createAttribute_error.phpt b/ext/dom/DOMDocument_createAttribute_error.phpt new file mode 100644 index 0000000000..3b318d40d2 --- /dev/null +++ b/ext/dom/DOMDocument_createAttribute_error.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test DOMDocument::createAttribute() for expected expection thrown when wrong parameter passed +--FILE-- +createAttribute(0); +} +catch(DOMException $e) { + $code = $e->getCode(); + if(DOM_INVALID_CHARACTER_ERR === $code) { + echo "PASS"; + } + else { + echo 'Wrong exception code'; + } +} +catch(Exception $e) { + echo 'Wrong exception thrown'; +} + +?> +--EXPECTF-- +PASS diff --git a/ext/dom/DOMDocument_createAttribute_error1.phpt b/ext/dom/DOMDocument_createAttribute_error1.phpt new file mode 100644 index 0000000000..153b18b5a2 --- /dev/null +++ b/ext/dom/DOMDocument_createAttribute_error1.phpt @@ -0,0 +1,27 @@ +--TEST-- +DomDocument::createAttribute() - error test for DomDocument::createAttribute() +--CREDITS-- +Muhammad Khalid Adnan +# TestFest 2008 +--FILE-- +createElement("para"); +$newnode = $doc->appendChild($node); + +try { + $failed_test_attribute = $doc->createAttribute("ha haha"); + $node->appendChild($failed_test_attribute); + + echo $doc->saveXML(); +} +catch (DOMException $e) { + echo 'Test failed!', PHP_EOL; +} + +?> +--EXPECT-- +Test failed! + diff --git a/ext/dom/DOMDocument_createAttribute_variation.phpt b/ext/dom/DOMDocument_createAttribute_variation.phpt new file mode 100644 index 0000000000..f00493455c --- /dev/null +++ b/ext/dom/DOMDocument_createAttribute_variation.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test DOMDocument::createAttribute() for expected return value +--FILE-- +createAttribute('string'); +echo get_class($attr); + +?> +--EXPECTF-- +DOMAttr