diff options
Diffstat (limited to 'ext/pcre/tests')
| -rw-r--r-- | ext/pcre/tests/002.phpt | 2 | ||||
| -rw-r--r-- | ext/pcre/tests/bug33200.phpt | 13 | ||||
| -rw-r--r-- | ext/pcre/tests/null_bytes.phpt | 42 | ||||
| -rw-r--r-- | ext/pcre/tests/preg_match_all_basic.phpt | 12 | ||||
| -rw-r--r-- | ext/pcre/tests/preg_match_all_error.phpt | 7 |
5 files changed, 57 insertions, 19 deletions
diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt index 726390c77e..00f68f3651 100644 --- a/ext/pcre/tests/002.phpt +++ b/ext/pcre/tests/002.phpt @@ -20,7 +20,7 @@ var_dump(preg_replace('/(.)/e', 'for ($', 'abc')); Warning: preg_match() expects at least 2 parameters, 0 given in %s002.php on line 3 bool(false) -Warning: preg_match_all() expects at least 3 parameters, 0 given in %s002.php on line 4 +Warning: preg_match_all() expects at least 2 parameters, 0 given in %s002.php on line 4 bool(false) Warning: preg_match_all(): Invalid flags specified in %s002.php on line 5 diff --git a/ext/pcre/tests/bug33200.phpt b/ext/pcre/tests/bug33200.phpt deleted file mode 100644 index ddbb06519b..0000000000 --- a/ext/pcre/tests/bug33200.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Bug #33200 (magic_quotes_sybase = On makes 'e' modifier misbehave) ---INI-- -magic_quotes_sybase=1 ---FILE-- -<?php -$str = 'some \'$sample\' text'; -$str = preg_replace("/(some.*text)/e", "strtoupper('\\1')", $str); -echo $str . "\r\n"; -?> ---EXPECT-- -Deprecated: Directive 'magic_quotes_sybase' is deprecated in PHP 5.3 and greater in Unknown on line 0 -SOME '$SAMPLE' TEXT diff --git a/ext/pcre/tests/null_bytes.phpt b/ext/pcre/tests/null_bytes.phpt new file mode 100644 index 0000000000..9a3f433ffb --- /dev/null +++ b/ext/pcre/tests/null_bytes.phpt @@ -0,0 +1,42 @@ +--TEST-- +Zero byte test +--FILE-- +<?php + +preg_match("\0//i", ""); +preg_match("/\0/i", ""); +preg_match("//\0i", ""); +preg_match("//i\0", ""); +preg_match("/\\\0/i", ""); + +preg_match("\0[]i", ""); +preg_match("[\0]i", ""); +preg_match("[]\0i", ""); +preg_match("[]i\0", ""); +preg_match("[\\\0]i", ""); + +preg_replace("/foo/e\0/i", "echo('Eek');", ""); + +?> +--EXPECTF-- +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 3 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 4 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 5 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 6 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 7 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 9 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 10 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 11 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 12 + +Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 13 + +Warning: preg_replace(): Null byte in regex in %snull_bytes.php on line 15 diff --git a/ext/pcre/tests/preg_match_all_basic.phpt b/ext/pcre/tests/preg_match_all_basic.phpt index 06dec1cb45..20c4a96be4 100644 --- a/ext/pcre/tests/preg_match_all_basic.phpt +++ b/ext/pcre/tests/preg_match_all_basic.phpt @@ -3,7 +3,7 @@ Test preg_match_all() function : basic functionality --FILE-- <?php /* -* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]]) +* proto int preg_match_all(string pattern, string subject, [array subpatterns [, int flags [, int offset]]]) * Function is implemented in ext/pcre/php_pcre.c */ $string = 'Hello, world! This is a test. This is another test. \[4]. 34534 string.'; @@ -17,6 +17,12 @@ var_dump(preg_match_all('/\d{2}$/', $string, $match4)); //tries to find 2 digits var_dump($match4); var_dump(preg_match_all('/(This is a ){2}(.*)\stest/', $string, $match5)); //tries to find "This is aThis is a [...] test" (0 matches) var_dump($match5); + +// Test not passing in a subpatterns array. +var_dump(preg_match_all('/test/', $string)); +var_dump(preg_match_all('/this isn\'t in the string/', $string)); +var_dump(preg_match_all('/world/', $string)); +var_dump(preg_match_all('/[0-9]/', $string)); ?> --EXPECTF-- int(1) @@ -80,3 +86,7 @@ array(3) { array(0) { } } +int(2) +int(0) +int(1) +int(6) diff --git a/ext/pcre/tests/preg_match_all_error.phpt b/ext/pcre/tests/preg_match_all_error.phpt index 2371ccfef1..f6e89284bb 100644 --- a/ext/pcre/tests/preg_match_all_error.phpt +++ b/ext/pcre/tests/preg_match_all_error.phpt @@ -21,8 +21,7 @@ var_dump(preg_match_all($pattern, $subject, $matches, $flags, $offset, $extra_ar // Testing preg_match_all withone less than the expected number of arguments echo "\n-- Testing preg_match_all() function with less than expected no. of arguments --\n"; $pattern = '/\w/'; -$subject = 'string_val'; -var_dump(preg_match_all($pattern, $subject)); +var_dump(preg_match_all($pattern)); echo "Done" ?> --EXPECTF-- @@ -30,7 +29,7 @@ echo "Done" -- Testing preg_match_all() function with Zero arguments -- -Warning: preg_match_all() expects at least 3 parameters, 0 given in %spreg_match_all_error.php on line %d +Warning: preg_match_all() expects at least 2 parameters, 0 given in %spreg_match_all_error.php on line %d bool(false) -- Testing preg_match_all() function with more than expected no. of arguments -- @@ -40,6 +39,6 @@ bool(false) -- Testing preg_match_all() function with less than expected no. of arguments -- -Warning: preg_match_all() expects at least 3 parameters, 2 given in %spreg_match_all_error.php on line %d +Warning: preg_match_all() expects at least 2 parameters, 1 given in %spreg_match_all_error.php on line %d bool(false) Done |
