summaryrefslogtreecommitdiff
path: root/ext/pcre/tests/preg_replace_callback_error1.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/pcre/tests/preg_replace_callback_error1.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/pcre/tests/preg_replace_callback_error1.phpt')
-rw-r--r--ext/pcre/tests/preg_replace_callback_error1.phpt59
1 files changed, 59 insertions, 0 deletions
diff --git a/ext/pcre/tests/preg_replace_callback_error1.phpt b/ext/pcre/tests/preg_replace_callback_error1.phpt
new file mode 100644
index 0000000..a00b97c
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback_error1.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test preg_replace_callback() function : error
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_replace_callback reacts to being passed the wrong type of regex argument
+*/
+echo "*** Testing preg_replace_callback() : error conditions ***\n";
+$regex_array = array('abcdef', //Regex without delimiters
+'/[a-zA-Z]', //Regex without closing delimiter
+'[a-zA-Z]/', //Regex without opening delimiter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/'); //Regex string
+$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
+function integer_word($matches) {
+ global $replacement;
+ return $replacement[$matches[0]];
+}
+$subject = 'number 1.';
+foreach($regex_array as $regex_value) {
+ print "\nArg value is $regex_value\n";
+ var_dump(preg_replace_callback($regex_value, 'integer_word', $subject));
+}
+?>
+===Done===
+--EXPECTF--
+*** Testing preg_replace_callback() : error conditions ***
+
+Arg value is abcdef
+
+Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in %s on line %d
+NULL
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_replace_callback(): No ending delimiter '/' found in %s on line %d
+NULL
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_replace_callback(): Unknown modifier '/' in %s on line %d
+NULL
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_replace_callback(): Unknown modifier 'F' in %s on line %d
+NULL
+
+Arg value is Array
+string(9) "number 1."
+
+Arg value is /[a-zA-Z]/
+string(3) " 1."
+===Done=== \ No newline at end of file