summaryrefslogtreecommitdiff
path: root/ext/simplexml
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-05-31 21:30:46 +0200
committerAnatol Belski <ab@php.net>2015-05-31 21:30:46 +0200
commit6f1c006b6d9c25324acdff421dbeee8a8a901230 (patch)
treec1c48706593ed2cbba700e98dfd0439a197b961d /ext/simplexml
parent021effbe977083bfce7387aed8e006f2eeb8e50a (diff)
parentb24fedbd24cef13dab0198f154db4fdaf3c9b3eb (diff)
downloadphp-git-6f1c006b6d9c25324acdff421dbeee8a8a901230.tar.gz
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: split the original test to check behaviour diff on 32- and 64-bit recovered original meaning of SXE xpath test
Diffstat (limited to 'ext/simplexml')
-rw-r--r--ext/simplexml/tests/SimpleXMLElement_xpath.phpt9
-rw-r--r--ext/simplexml/tests/SimpleXMLElement_xpath_1.phpt22
-rw-r--r--ext/simplexml/tests/SimpleXMLElement_xpath_2.phpt22
3 files changed, 52 insertions, 1 deletions
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
index 4a613c2e51..fb7e6e90f0 100644
--- a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
@@ -2,7 +2,14 @@
Testing xpath() with invalid XML
--FILE--
<?php
-$xml = @simplexml_load_string("XXXXXXX^",$x,0x6000000000000001);
+// gracefully recover from parsing of invalid XML; not available in PHP
+const XML_PARSE_RECOVER = 1;
+
+// we're not interested in checking concrete warnings regarding invalid XML
+$xml = @simplexml_load_string("XXXXXXX^", 'SimpleXMLElement', XML_PARSE_RECOVER);
+
+// $xml is supposed to hold a SimpleXMLElement, but not FALSE/NULL
var_dump($xml->xpath("BBBB"));
+?>
--EXPECT--
bool(false)
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_1.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath_1.phpt
new file mode 100644
index 0000000000..bf7e0318c9
--- /dev/null
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath_1.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Testing xpath() with invalid XML
+--SKIPIF--
+<?php
+if (PHP_MAJOR_VERSION != 5) die("skip this test is for PHP 5 only");
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
+?>
+--FILE--
+<?php
+$xml = simplexml_load_string("XXXXXXX^",$x,0x6000000000000001);
+var_dump($xml->xpath("BBBB"));
+?>
+--EXPECTF--
+Notice: Undefined variable: x in %s on line %d
+
+Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in %s on line %d
+
+Warning: simplexml_load_string(): XXXXXXX^ in %s on line %d
+
+Warning: simplexml_load_string(): ^ in %s on line %d
+
+Fatal error: Call to a member function xpath() on a non-object in %s on line %d
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_2.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath_2.phpt
new file mode 100644
index 0000000000..78f8b3e59f
--- /dev/null
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath_2.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Testing xpath() with invalid XML
+--SKIPIF--
+<?php
+if (PHP_MAJOR_VERSION != 5) die("skip this test is for PHP 5 only");
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
+?>
+--FILE--
+<?php
+$xml = simplexml_load_string("XXXXXXX^",$x,0x6000000000000001);
+var_dump($xml->xpath("BBBB"));
+?>
+--EXPECTF--
+Notice: Undefined variable: x in %s on line %d
+
+Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in %s on line %d
+
+Warning: simplexml_load_string(): XXXXXXX^ in %s on line %d
+
+Warning: simplexml_load_string(): ^ in %s on line %d
+bool(false)
+