com php-src: split simplexml tests for 7: ext/simplexml/tests/S impleXMLElement_xpath.phpt ext/simplexml/tests/SimpleXMLE lement_xpath_3.phpt
ext/simplexml/tests/SimpleXMLElem ent_xpath_4.phpt
| From: | Anatol Belski | Date: | Sun, 31 May 2015 19:35:21 +0000 |
| Subject: | com php-src: split simplexml tests for 7: ext/simplexml/tests/S impleXMLElement_xpath.phpt ext/simplexml/tests/SimpleXMLE lement_xpath_3.phpt ext/simplexml/tests/SimpleXMLElem ent_xpath_4.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87022@lists.php.net to get a copy of this message | ||
Commit: c1401ad7b6948248ce8c9a33f1acbc706baae923
Author: Christoph M. Becker <cmbecker69@gmx.de> Sun, 31 May 2015 21:35:21 +0200
Committer: Anatol Belski <ab@php.net> Sun, 31 May 2015 21:35:21 +0200
Parents: 4309f1661475ae34d9dd48d92eb219ee014b0fdb
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c1401ad7b6948248ce8c9a33f1acbc706baae923
Log:
split simplexml tests for 7
Changed paths:
M ext/simplexml/tests/SimpleXMLElement_xpath.phpt
A ext/simplexml/tests/SimpleXMLElement_xpath_3.phpt
A ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
Diff:
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
index 7926ceb..fb7e6e9 100644
--- a/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath.phpt
@@ -1,17 +1,15 @@
--TEST--
Testing xpath() with invalid XML
---SKIPIF--
-<?php PHP_INT_SIZE == 4 or die("skip - 32-bit 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() expects parameter 3 to be integer, float given in %s on line %d
+// gracefully recover from parsing of invalid XML; not available in PHP
+const XML_PARSE_RECOVER = 1;
-Fatal error: Uncaught EngineException: Call to a member function xpath() on null in %s:%d
-Stack trace:
-#0 {main}
- thrown in %s on line %d
+// 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_3.phpt
b/ext/simplexml/tests/SimpleXMLElement_xpath_3.phpt
new file mode 100644
index 0000000..e2997f1
--- /dev/null
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath_3.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Testing xpath() with invalid XML
+--SKIPIF--
+<?php
+if (PHP_MAJOR_VERSION < 7) die("skip this test is for PHP 7+ 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() expects parameter 3 to be integer, float given in %s on line %d
+
+Fatal error: Uncaught EngineException: Call to a member function xpath() on null in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
new file mode 100644
index 0000000..d4d7097
--- /dev/null
+++ b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Testing xpath() with invalid XML
+--SKIPIF--
+<?php
+if (PHP_MAJOR_VERSION < 7) die("skip this test is for PHP 7+ 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)
+