diff options
Diffstat (limited to 'ext/simplexml/tests')
| -rwxr-xr-x | ext/simplexml/tests/032.phpt | 2 | ||||
| -rwxr-xr-x | ext/simplexml/tests/bug35785.phpt | 2 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug36611.phpt | 2 | ||||
| -rwxr-xr-x | ext/simplexml/tests/bug37565.phpt | 31 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug38347.phpt | 28 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug38354.phpt | 28 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug38424.phpt | 26 | ||||
| -rwxr-xr-x | ext/simplexml/tests/profile12.phpt | 74 | ||||
| -rwxr-xr-x | ext/simplexml/tests/profile13.phpt | 75 | ||||
| -rwxr-xr-x | ext/simplexml/tests/simplexml_import_dom.phpt | 4 |
10 files changed, 269 insertions, 3 deletions
diff --git a/ext/simplexml/tests/032.phpt b/ext/simplexml/tests/032.phpt index 5c2225146..48bc887ec 100755 --- a/ext/simplexml/tests/032.phpt +++ b/ext/simplexml/tests/032.phpt @@ -39,7 +39,7 @@ var_dump($people2 == $people1); ?> ===DONE=== --EXPECTF-- -bool(true) +bool(false) bool(false) bool(false) ===DONE=== diff --git a/ext/simplexml/tests/bug35785.phpt b/ext/simplexml/tests/bug35785.phpt index de65a1956..096ab7a68 100755 --- a/ext/simplexml/tests/bug35785.phpt +++ b/ext/simplexml/tests/bug35785.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #35785 (SimpleXML memory read error) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- <?php diff --git a/ext/simplexml/tests/bug36611.phpt b/ext/simplexml/tests/bug36611.phpt index fdfed0d01..835e926fe 100644 --- a/ext/simplexml/tests/bug36611.phpt +++ b/ext/simplexml/tests/bug36611.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #36611 (assignment to SimpleXML object attribute changes argument type to string) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- <?php diff --git a/ext/simplexml/tests/bug37565.phpt b/ext/simplexml/tests/bug37565.phpt new file mode 100755 index 000000000..e04f9577f --- /dev/null +++ b/ext/simplexml/tests/bug37565.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #37565 Using reflection::export with simplexml causing a crash +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +function my_error_handler($errno, $errstr, $errfile, $errline) { + echo "Error: $errstr\n"; +} + +set_error_handler('my_error_handler'); + +class Setting extends ReflectionObject +{ +} + +Reflection::export(simplexml_load_string('<test/>', 'Setting')); + +Reflection::export(simplexml_load_file('data:,<test/>', 'Setting')); + +?> +===DONE=== +--EXPECTF-- +Error: simplexml_load_string() expects parameter 2 to be a class name derived from SimpleXMLElement, 'Setting' given +Error: Argument 1 passed to Reflection::export() must implement interface Reflector, null given +Error: Reflection::export() expects parameter 1 to be Reflector, null given +Error: simplexml_load_file() expects parameter 2 to be a class name derived from SimpleXMLElement, 'Setting' given +Error: Argument 1 passed to Reflection::export() must implement interface Reflector, null given +Error: Reflection::export() expects parameter 1 to be Reflector, null given +===DONE=== diff --git a/ext/simplexml/tests/bug38347.phpt b/ext/simplexml/tests/bug38347.phpt new file mode 100644 index 000000000..c25fccea2 --- /dev/null +++ b/ext/simplexml/tests/bug38347.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #38347 (Segmentation fault when using foreach with an unknown/empty SimpleXMLElement) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +function iterate($xml) +{ + print_r($xml); + foreach ($xml->item as $item) { + echo "This code will crash!"; + } +} + +$xmlstr = "<xml><item>Item 1</item><item>Item 2</item></xml>"; +$xml = simplexml_load_string($xmlstr); +iterate($xml->unknown); + +echo "Done\n"; +?> +--EXPECTF-- +SimpleXMLElement Object +( +) + +Warning: iterate(): Node no longer exists in %s on line %d +Done diff --git a/ext/simplexml/tests/bug38354.phpt b/ext/simplexml/tests/bug38354.phpt new file mode 100644 index 000000000..d2fcde11c --- /dev/null +++ b/ext/simplexml/tests/bug38354.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #38354 (Unwanted reformatting of XML when using AsXML) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml = simplexml_load_string( +'<code> + <a href="javascript:alert(\'1\');"><strong>Item Two</strong></a> +</code>' +); + +foreach ($xml->xpath("//*") as $element) { + var_dump($element->asXML()); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(101) "<?xml version="1.0"?> +<code> + <a href="javascript:alert('1');"><strong>Item Two</strong></a> +</code> +" +string(62) "<a href="javascript:alert('1');"><strong>Item Two</strong></a>" +string(25) "<strong>Item Two</strong>" +Done diff --git a/ext/simplexml/tests/bug38424.phpt b/ext/simplexml/tests/bug38424.phpt new file mode 100644 index 000000000..baab45fe5 --- /dev/null +++ b/ext/simplexml/tests/bug38424.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #38424 (Different attribute assignment if new or exists) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml = simplexml_load_string('<xml></xml>'); + +$str = "abc & def" ; + +$xml["a1"] = "" ; +$xml["a1"] = htmlspecialchars($str,ENT_NOQUOTES) ; + +$xml["a2"] = htmlspecialchars($str,ENT_NOQUOTES) ; + +$xml["a3"] = "" ; +$xml["a3"] = $str ; + +$xml["a4"] = $str ; + +echo $xml->asXML(); +?> +--EXPECT-- +<?xml version="1.0"?> +<xml a1="abc &amp; def" a2="abc &amp; def" a3="abc & def" a4="abc & def"/> diff --git a/ext/simplexml/tests/profile12.phpt b/ext/simplexml/tests/profile12.phpt new file mode 100755 index 000000000..51a0d3553 --- /dev/null +++ b/ext/simplexml/tests/profile12.phpt @@ -0,0 +1,74 @@ +--TEST-- +SimpleXML [profile]: Accessing namespaced root and non namespaced children +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version="1.0" encoding="utf-8"?> +<soap:Envelope +xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xmlns:xsd="http://www.w3.org/2001/XMLSchema" +> +<soap:Body> +<businessList foo="bar"> +<businessInfo businessKey="bla"/> +</businessList> +</soap:Body> +</soap:Envelope> +EOF; + +$sxe = simplexml_load_string($xml); +$nsl = $sxe->getNamespaces(); +var_dump($nsl); + +$sxe = simplexml_load_string($xml, NULL, 0, $nsl['soap']); +var_dump($sxe->Body); +var_dump($sxe->Body->children('')); +var_dump($sxe->Body->children('')->businessList); + +?> +===DONE=== +--EXPECTF-- +array(1) { + ["soap"]=> + string(41) "http://schemas.xmlsoap.org/soap/envelope/" +} +object(SimpleXMLElement)#%s (0) { +} +object(SimpleXMLElement)#%s (1) { + ["businessList"]=> + object(SimpleXMLElement)#%s (2) { + ["@attributes"]=> + array(1) { + ["foo"]=> + string(3) "bar" + } + ["businessInfo"]=> + object(SimpleXMLElement)#%s (1) { + ["@attributes"]=> + array(1) { + ["businessKey"]=> + string(3) "bla" + } + } + } +} +object(SimpleXMLElement)#%s (2) { + ["@attributes"]=> + array(1) { + ["foo"]=> + string(3) "bar" + } + ["businessInfo"]=> + object(SimpleXMLElement)#%s (1) { + ["@attributes"]=> + array(1) { + ["businessKey"]=> + string(3) "bla" + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/profile13.phpt b/ext/simplexml/tests/profile13.phpt new file mode 100755 index 000000000..2ae89e744 --- /dev/null +++ b/ext/simplexml/tests/profile13.phpt @@ -0,0 +1,75 @@ +--TEST-- +SimpleXML [profile]: Accessing by namespace prefix +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version="1.0" encoding="utf-8"?> +<soap:Envelope +xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xmlns:xsd="http://www.w3.org/2001/XMLSchema" +> +<soap:Body> +<businessList foo="bar"> +<businessInfo businessKey="bla"/> +</businessList> +</soap:Body> +</soap:Envelope> +EOF; + +$sxe = simplexml_load_string($xml); +var_dump($sxe->children('soap', 1)); + +$sxe = simplexml_load_string($xml, NULL, 0, 'soap', 1); +var_dump($sxe->Body); +var_dump($sxe->Body->children('')); +var_dump($sxe->Body->children('')->businessList); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +object(SimpleXMLElement)#%d (1) { + ["Body"]=> + object(SimpleXMLElement)#%d (0) { + } +} +object(SimpleXMLElement)#%d (0) { +} +object(SimpleXMLElement)#%d (1) { + ["businessList"]=> + object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["foo"]=> + string(3) "bar" + } + ["businessInfo"]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["businessKey"]=> + string(3) "bla" + } + } + } +} +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["foo"]=> + string(3) "bar" + } + ["businessInfo"]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["businessKey"]=> + string(3) "bla" + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/simplexml_import_dom.phpt b/ext/simplexml/tests/simplexml_import_dom.phpt index 76e7f041d..e108e0554 100755 --- a/ext/simplexml/tests/simplexml_import_dom.phpt +++ b/ext/simplexml/tests/simplexml_import_dom.phpt @@ -1,8 +1,8 @@ --TEST-- SimpleXML [interop]: simplexml_import_dom --SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> -<?php if (!extension_loaded("dom")) print "skip. dom extension not loaded"; ?> +<?php if (!extension_loaded("simplexml")) die("skip"); ?> +<?php if (!extension_loaded("dom")) die("skip dom extension not loaded"); ?> --FILE-- <?php $dom = new domDocument; |
