From: Robert Nicholson Date: Wed, 21 Nov 2007 18:23:02 +0000 (+0000) Subject: Add some more pcre tests X-Git-Tag: RELEASE_2_0_0a1~1314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0601e161d6546e0147c8c67d3dc9508dbb89702;p=php Add some more pcre tests --- diff --git a/ext/pcre/tests/preg_grep_basic.phpt b/ext/pcre/tests/preg_grep_basic.phpt new file mode 100644 index 0000000000..8383db3459 --- /dev/null +++ b/ext/pcre/tests/preg_grep_basic.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test preg_grep() function : basic functionality +--FILE-- + +--EXPECT-- +array(5) { + [0]=> + string(22) "HTTP://WWW.EXAMPLE.COM" + [1]=> + string(11) "/index.html" + [2]=> + string(11) "/info/stat/" + [3]=> + string(29) "http://test.uk.com/index/html" + [4]=> + string(17) "/display/dept.php" +} +array(2) { + [0]=> + string(22) "HTTP://WWW.EXAMPLE.COM" + [3]=> + string(29) "http://test.uk.com/index/html" +} +array(5) { + [0]=> + string(22) "HTTP://WWW.EXAMPLE.COM" + [1]=> + string(11) "/index.html" + [2]=> + string(11) "/info/stat/" + [3]=> + string(29) "http://test.uk.com/index/html" + [4]=> + string(17) "/display/dept.php" +} +array(1) { + [3]=> + string(29) "http://test.uk.com/index/html" +} +array(0) { +} +array(3) { + [1]=> + string(11) "/index.html" + [2]=> + string(11) "/info/stat/" + [4]=> + string(17) "/display/dept.php" +} + +--UEXPECTF-- +array(5) { + [0]=> + unicode(22) "HTTP://WWW.EXAMPLE.COM" + [1]=> + unicode(11) "/index.html" + [2]=> + unicode(11) "/info/stat/" + [3]=> + unicode(29) "http://test.uk.com/index/html" + [4]=> + unicode(17) "/display/dept.php" +} +array(2) { + [0]=> + unicode(22) "HTTP://WWW.EXAMPLE.COM" + [3]=> + unicode(29) "http://test.uk.com/index/html" +} +array(5) { + [0]=> + unicode(22) "HTTP://WWW.EXAMPLE.COM" + [1]=> + unicode(11) "/index.html" + [2]=> + unicode(11) "/info/stat/" + [3]=> + unicode(29) "http://test.uk.com/index/html" + [4]=> + unicode(17) "/display/dept.php" +} +array(1) { + [3]=> + unicode(29) "http://test.uk.com/index/html" +} +array(0) { +} +array(3) { + [1]=> + unicode(11) "/index.html" + [2]=> + unicode(11) "/info/stat/" + [4]=> + unicode(17) "/display/dept.php" +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_grep_error.phpt b/ext/pcre/tests/preg_grep_error.phpt new file mode 100644 index 0000000000..f2afdb9d26 --- /dev/null +++ b/ext/pcre/tests/preg_grep_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test preg_grep() function : error conditions - wrong numbers of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_grep() : error conditions *** + +-- Testing preg_grep() function with Zero arguments -- + +Warning: preg_grep() expects at least 2 parameters, 0 given in %spreg_grep_error.php on line %d +NULL + +-- Testing preg_grep() function with more than expected no. of arguments -- + +Warning: preg_grep() expects at most 3 parameters, 4 given in %spreg_grep_error.php on line %d +NULL + +-- Testing preg_grep() function with less than expected no. of arguments -- + +Warning: preg_grep() expects at least 2 parameters, 1 given in %spreg_grep_error.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_grep_error1.phpt b/ext/pcre/tests/preg_grep_error1.phpt new file mode 100644 index 0000000000..f5229b73cd --- /dev/null +++ b/ext/pcre/tests/preg_grep_error1.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test preg_grep() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- + +*** Testing preg_grep() : error conditions *** + +Arg value is abcdef + +Warning: preg_grep(): Delimiter must not be alphanumeric or backslash in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_grep() expects parameter 1 to be string (Unicode or binary), array given in %spreg_grep_error1.php on line %d +NULL + +Arg value is /[a-zA-Z]/ +array(2) { + [1]=> + string(3) "abc" + [2]=> + string(4) "test" +} + +Warning: preg_grep() expects parameter 1 to be string (Unicode or binary), object given in %spreg_grep_error1.php on line %d +NULL +Done +--UEXPECTF-- +*** Testing preg_grep() : error conditions *** + +Arg value is abcdef + +Warning: preg_grep(): Delimiter must not be alphanumeric or backslash in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_grep() expects parameter 1 to be string (Unicode or binary), array given in %spreg_grep_error1.php on line %d +NULL + +Arg value is /[a-zA-Z]/ +array(2) { + [1]=> + unicode(3) "abc" + [2]=> + unicode(4) "test" +} + +Warning: preg_grep() expects parameter 1 to be string (Unicode or binary), object given in %spreg_grep_error1.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_grep_error2.phpt b/ext/pcre/tests/preg_grep_error2.phpt new file mode 100644 index 0000000000..b9a239594a --- /dev/null +++ b/ext/pcre/tests/preg_grep_error2.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test preg_grep() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_grep() : error conditions *** + +Arg value is: this is a string + +Warning: preg_grep() expects parameter 2 to be array, string given in %spreg_grep_error2.php on line %d +NULL + +Arg value is: Array +array(2) { + [0]=> + string(7) "this is" + [1]=> + string(10) "a subarray" +} + +Warning: preg_grep() expects parameter 2 to be array, object given in %spreg_grep_error2.php on line %d +NULL +Done +--UEXPECTF-- +*** Testing preg_grep() : error conditions *** + +Arg value is: this is a string + +Warning: preg_grep() expects parameter 2 to be array, Unicode string given in %spreg_grep_error2.php on line %d +NULL + +Arg value is: Array +array(2) { + [0]=> + unicode(7) "this is" + [1]=> + unicode(10) "a subarray" +} + +Warning: preg_grep() expects parameter 2 to be array, object given in %spreg_grep_error2.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_match_all_basic.phpt b/ext/pcre/tests/preg_match_all_basic.phpt new file mode 100644 index 0000000000..154d8a4240 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_basic.phpt @@ -0,0 +1,145 @@ +--TEST-- +Test preg_match_all() function : basic functionality +--FILE-- + +--EXPECTF-- +int(1) +array(1) { + [0]=> + array(1) { + [0]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + int(61) + } + } +} +int(2) +array(2) { + [0]=> + array(2) { + [0]=> + string(15) "This is a test." + [1]=> + string(5) " test" + } + [1]=> + array(2) { + [0]=> + string(21) "This is another test." + [1]=> + string(11) "nother test" + } +} +int(1) +array(2) { + [0]=> + array(1) { + [0]=> + string(21) ". \[4]. 34534 string." + } + [1]=> + array(1) { + [0]=> + string(17) "[4]. 34534 string" + } +} +int(0) +array(1) { + [0]=> + array(0) { + } +} +int(0) +array(3) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } + [2]=> + array(0) { + } +} + +--UEXPECTF-- +int(1) +array(1) { + [0]=> + array(1) { + [0]=> + array(2) { + [0]=> + unicode(1) "3" + [1]=> + int(61) + } + } +} +int(2) +array(2) { + [0]=> + array(2) { + [0]=> + unicode(15) "This is a test." + [1]=> + unicode(5) " test" + } + [1]=> + array(2) { + [0]=> + unicode(21) "This is another test." + [1]=> + unicode(11) "nother test" + } +} +int(1) +array(2) { + [0]=> + array(1) { + [0]=> + unicode(21) ". \[4]. 34534 string." + } + [1]=> + array(1) { + [0]=> + unicode(17) "[4]. 34534 string" + } +} +int(0) +array(1) { + [0]=> + array(0) { + } +} +int(0) +array(3) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } + [2]=> + array(0) { + } +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_match_all_error.phpt b/ext/pcre/tests/preg_match_all_error.phpt new file mode 100644 index 0000000000..2371ccfef1 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test preg_match_all() function : error conditions - incorrect number of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_match_all() : error conditions *** + +-- 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 +bool(false) + +-- Testing preg_match_all() function with more than expected no. of arguments -- + +Warning: preg_match_all() expects at most 5 parameters, 6 given in %spreg_match_all_error.php on line %d +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 +bool(false) +Done diff --git a/ext/pcre/tests/preg_match_all_error1.phpt b/ext/pcre/tests/preg_match_all_error1.phpt new file mode 100644 index 0000000000..3cb607baa0 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error1.phpt @@ -0,0 +1,134 @@ +--TEST-- +Test preg_match_all() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- +*** Testing preg_match_all() : error conditions *** + +Arg value is abcdef + +Warning: preg_match_all(): Delimiter must not be alphanumeric or backslash in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z] + +Warning: preg_match_all(): No ending delimiter '/' found in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is [a-zA-Z]/ + +Warning: preg_match_all(): Unknown modifier '/' in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z]/F + +Warning: preg_match_all(): Unknown modifier 'F' in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is Array + +Warning: preg_match_all() expects parameter 1 to be string (Unicode or binary), array given in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z]/ +int(4) +array(1) { + [0]=> + array(4) { + [0]=> + string(1) "t" + [1]=> + string(1) "e" + [2]=> + string(1) "s" + [3]=> + string(1) "t" + } +} + +Warning: preg_match_all() expects parameter 1 to be string (Unicode or binary), object given in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +--UEXPECTF-- +*** Testing preg_match_all() : error conditions *** + +Arg value is abcdef + +Warning: preg_match_all(): Delimiter must not be alphanumeric or backslash in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z] + +Warning: preg_match_all(): No ending delimiter '/' found in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is [a-zA-Z]/ + +Warning: preg_match_all(): Unknown modifier '/' in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z]/F + +Warning: preg_match_all(): Unknown modifier 'F' in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is Array + +Warning: preg_match_all() expects parameter 1 to be string (Unicode or binary), array given in %spreg_match_all_error1.php on line %d +bool(false) +NULL + +Arg value is /[a-zA-Z]/ +int(4) +array(1) { + [0]=> + array(4) { + [0]=> + unicode(1) "t" + [1]=> + unicode(1) "e" + [2]=> + unicode(1) "s" + [3]=> + unicode(1) "t" + } +} + +Warning: preg_match_all() expects parameter 1 to be string (Unicode or binary), object given in %spreg_match_all_error1.php on line %d +bool(false) +NULL \ No newline at end of file diff --git a/ext/pcre/tests/preg_match_all_error2.phpt b/ext/pcre/tests/preg_match_all_error2.phpt new file mode 100644 index 0000000000..c9d2c89f48 --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error2.phpt @@ -0,0 +1,84 @@ +--TEST-- +Test preg_match_all() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_match_all() : error conditions *** + +Warning: preg_match_all() expects parameter 2 to be string (Unicode or binary), object given in %spreg_match_all_error2.php on line %d +bool(false) +NULL + +Arg value is: Array + +Warning: preg_match_all() expects parameter 2 to be string (Unicode or binary), array given in %spreg_match_all_error2.php on line %d +bool(false) +NULL + +Arg value is: test +int(4) +array(1) { + [0]=> + array(4) { + [0]=> + string(1) "t" + [1]=> + string(1) "e" + [2]=> + string(1) "s" + [3]=> + string(1) "t" + } +} +Done + +--UEXPECTF-- +*** Testing preg_match_all() : error conditions *** + +Warning: preg_match_all() expects parameter 2 to be string (Unicode or binary), object given in %spreg_match_all_error2.php on line %d +bool(false) +NULL + +Arg value is: Array + +Warning: preg_match_all() expects parameter 2 to be string (Unicode or binary), array given in %spreg_match_all_error2.php on line %d +bool(false) +NULL + +Arg value is: test +int(4) +array(1) { + [0]=> + array(4) { + [0]=> + unicode(1) "t" + [1]=> + unicode(1) "e" + [2]=> + unicode(1) "s" + [3]=> + unicode(1) "t" + } +} +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_match_all_error3.phpt b/ext/pcre/tests/preg_match_all_error3.phpt new file mode 100644 index 0000000000..b8b2ea211b --- /dev/null +++ b/ext/pcre/tests/preg_match_all_error3.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test preg_match_all() function : error conditions +--FILE-- + +--EXPECTF-- + +Fatal error: Only variables can be passed by reference in %spreg_match_all_error3.php on line %d diff --git a/ext/pcre/tests/preg_match_basic.phpt b/ext/pcre/tests/preg_match_basic.phpt new file mode 100644 index 0000000000..470663c2e8 --- /dev/null +++ b/ext/pcre/tests/preg_match_basic.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test preg_match() function : basic functionality +--FILE-- + + +--EXPECTF-- + +int(1) +array(1) { + [0]=> + string(7) "Hello, " +} +int(0) +array(0) { +} +int(1) +array(2) { + [0]=> + string(23) "[*], this is \ a string" + [1]=> + string(18) "this is \ a string" +} +int(1) +array(1) { + [0]=> + array(2) { + [0]=> + string(18) "this is \ a string" + [1]=> + int(19) + } +} +int(0) +array(0) { +} + + +--UEXPECTF-- +int(1) +array(1) { + [0]=> + unicode(7) "Hello, " +} +int(0) +array(0) { +} +int(1) +array(2) { + [0]=> + unicode(23) "[*], this is \ a string" + [1]=> + unicode(18) "this is \ a string" +} +int(1) +array(1) { + [0]=> + array(2) { + [0]=> + unicode(18) "this is \ a string" + [1]=> + int(19) + } +} +int(0) +array(0) { +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_match_error.phpt b/ext/pcre/tests/preg_match_error.phpt new file mode 100644 index 0000000000..ca1f128ada --- /dev/null +++ b/ext/pcre/tests/preg_match_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test preg_match() function : error conditions - wrong numbers of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_match() : error conditions *** + +-- Testing preg_match() function with Zero arguments -- + +Warning: preg_match() expects at least 2 parameters, 0 given in %spreg_match_error.php on line %d +bool(false) + +-- Testing preg_match() function with more than expected no. of arguments -- + +Warning: preg_match() expects at most 5 parameters, 6 given in %spreg_match_error.php on line %d +bool(false) + +-- Testing preg_match() function with less than expected no. of arguments -- + +Warning: preg_match() expects at least 2 parameters, 1 given in %spreg_match_error.php on line %d +bool(false) +Done diff --git a/ext/pcre/tests/preg_match_error1.phpt b/ext/pcre/tests/preg_match_error1.phpt new file mode 100644 index 0000000000..dae0112e99 --- /dev/null +++ b/ext/pcre/tests/preg_match_error1.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test preg_match() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- + +*** Testing preg_match() : error conditions *** + +Arg value is abcdef + +Warning: preg_match(): Delimiter must not be alphanumeric or backslash in %spreg_match_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_match(): No ending delimiter '/' found in %spreg_match_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_match(): Unknown modifier '/' in %spreg_match_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_match(): Unknown modifier 'F' in %spreg_match_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_match() expects parameter 1 to be string (Unicode or binary), array given in %spreg_match_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/ +int(1) + +Warning: preg_match() expects parameter 1 to be string (Unicode or binary), object given in %spreg_match_error1.php on line %d +bool(false) diff --git a/ext/pcre/tests/preg_match_error2.phpt b/ext/pcre/tests/preg_match_error2.phpt new file mode 100644 index 0000000000..10198d0994 --- /dev/null +++ b/ext/pcre/tests/preg_match_error2.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test preg_match() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- + +*** Testing preg_match() : error conditions *** + +Arg value is: this is a string +int(1) + +Arg value is: Array + +Warning: preg_match() expects parameter 2 to be string (Unicode or binary), array given in %spreg_match_error2.php on line %d +bool(false) + +Warning: preg_match() expects parameter 2 to be string (Unicode or binary), object given in %spreg_match_error2.php on line %d +bool(false) +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_quote_basic.phpt b/ext/pcre/tests/preg_quote_basic.phpt new file mode 100644 index 0000000000..2b9be8962c --- /dev/null +++ b/ext/pcre/tests/preg_quote_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test preg_quote() function : basic functionality +--FILE-- + +--EXPECT-- + +$string_before looks like: /this *-has \ metacharacters^ in $ +$string_after looks like: \/this \*-has \\ metacharacters\^ in \$, with metacharacters and / (set as delimiter) escaped +int(1) +array(1) { + [0]=> + string(58) "testing - /this *-has \ metacharacters^ in $ should work" +} +--UEXPECTF-- +$string_before looks like: /this *-has \ metacharacters^ in $ +$string_after looks like: \/this \*-has \\ metacharacters\^ in \$, with metacharacters and / (set as delimiter) escaped +int(1) +array(1) { + [0]=> + unicode(58) "testing - /this *-has \ metacharacters^ in $ should work" +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_quote_error.phpt b/ext/pcre/tests/preg_quote_error.phpt new file mode 100644 index 0000000000..30b832dbf9 --- /dev/null +++ b/ext/pcre/tests/preg_quote_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test preg_quote() function : error conditions - wrong numbers of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_quote() : error conditions *** + +-- Testing preg_quote() function with Zero arguments -- + +Warning: preg_quote() expects at least 1 parameter, 0 given in %spreg_quote_error.php on line %d +NULL + +-- Testing preg_quote() function with more than expected no. of arguments -- + +Warning: preg_quote() expects at most 2 parameters, 3 given in %spreg_quote_error.php on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_quote_error1.phpt b/ext/pcre/tests/preg_quote_error1.phpt new file mode 100644 index 0000000000..929fe3fa47 --- /dev/null +++ b/ext/pcre/tests/preg_quote_error1.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test preg_quote() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_quote() : error conditions *** + +Arg value is: this is a string +string(16) "this is a string" + +Arg value is: Array + +Warning: preg_quote() expects parameter 1 to be string, array given in %spreg_quote_error1.php on line %d +NULL + +Warning: preg_quote() expects parameter 1 to be string, object given in %spreg_quote_error1.php on line %d +NULL +Done +--UEXPECTF-- +*** Testing preg_quote() : error conditions *** + +Arg value is: this is a string +unicode(16) "this is a string" + +Arg value is: Array + +Warning: preg_quote() expects parameter 1 to be binary string, array given in %spreg_quote_error1.php on line %d +NULL + +Warning: preg_quote() expects parameter 1 to be binary string, object given in %spreg_quote_error1.php on line %d +NULL +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_replace_basic.phpt b/ext/pcre/tests/preg_replace_basic.phpt new file mode 100644 index 0000000000..cc7f55d23d --- /dev/null +++ b/ext/pcre/tests/preg_replace_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test preg_replace() function : basic functionality +--FILE-- +', 'This shouldn\'t work', $string)); //tries to find '- This is a string' at the end of a string but can't so replaces nothing and prints the unchanged $string. +var_dump(preg_replace('<[0-35-9]>', '4', $string)); //finds any number that's not 4 and replaces it with a 4 ('444444444') +var_dump(preg_replace('<\b[hH]\w{2,4}>', 'Bonjour', $string)); //finds h or H at the beginning of a word followed by 2-4 characters and replaces it with Bonjour (i.e. Hello -> Bonjour) (was finding the 'his' in This and replacing it) +var_dump(preg_replace('<(\w)\s*-\s*(\w)>', '\\1. \\2', $string)); //finds dashes with an indefinate amount of whitespace around them and replaces them with a full stop precedeby no spaces and followed by one space +var_dump(preg_replace('<(^[a-z]\w+)@(\w+)\.(\w+)\.([a-z]{2,}$)>', '\\1 at \\2 dot \\3 dot \\4', 'josmessa@uk.ibm.com')); //finds the e-mail address and replaces the @ and . with "at" and "dot" (uses backreferences) ('josmessa at uk dot ibm dot com') + +?> +--EXPECT-- + +string(54) "123456789 - Hello, world - This is a string." +string(54) "123456789 - Hello, world - This is a string." +string(54) "444444444 - Hello, world - This is a string." +string(56) "123456789 - Bonjour, world - This is a string." +string(42) "123456789. Hello, world. This is a string." +string(30) "josmessa at uk dot ibm dot com" + +--UEXPECTF-- +unicode(54) "123456789 - Hello, world - This is a string." +unicode(54) "123456789 - Hello, world - This is a string." +unicode(54) "444444444 - Hello, world - This is a string." +unicode(56) "123456789 - Bonjour, world - This is a string." +unicode(42) "123456789. Hello, world. This is a string." +unicode(30) "josmessa at uk dot ibm dot com" \ No newline at end of file diff --git a/ext/pcre/tests/preg_replace_callback_basic.phpt b/ext/pcre/tests/preg_replace_callback_basic.phpt new file mode 100644 index 0000000000..01d290a1b9 --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test preg_replace_callback() function : basic functionality +--FILE-- + +--EXPECTF-- +there are seven words in this sentence. +one two three 4 is now written in words +there are no numbers in this string +0 diff --git a/ext/pcre/tests/preg_replace_callback_error.phpt b/ext/pcre/tests/preg_replace_callback_error.phpt new file mode 100644 index 0000000000..b6ed1d1a95 --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_error.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test preg_replace_callback() function : error +--FILE-- + +--EXPECTF-- +***Testing preg_replace_callback() : error conditions*** + +-- Testing preg_replace_callback() function with Zero arguments -- + +Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %spreg_replace_callback_error.php on line %d +NULL + +-- Testing preg_replace_callback() function with more than expected no. of arguments -- + +Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %spreg_replace_callback_error.php on line %d +NULL + +-- Testing preg_replace_callback() function with less than expected no. of arguments -- + +Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %spreg_replace_callback_error.php on line %d +NULL +Done +--UEXPECTF-- +***Testing preg_replace_callback() : error conditions*** + +-- Testing preg_replace_callback() function with Zero arguments -- + +Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %spreg_replace_callback_error.php on line %d +NULL + +-- Testing preg_replace_callback() function with more than expected no. of arguments -- + +Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %spreg_replace_callback_error.php on line %d +NULL + +-- Testing preg_replace_callback() function with less than expected no. of arguments -- + +Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %spreg_replace_callback_error.php on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_replace_error.phpt b/ext/pcre/tests/preg_replace_error.phpt new file mode 100644 index 0000000000..2ef6c0d26f --- /dev/null +++ b/ext/pcre/tests/preg_replace_error.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test preg_replace() function : error - incorrect number of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_replace() : error conditions *** + +-- Testing preg_replace() function with zero arguments -- + +Warning: preg_replace() expects at least 3 parameters, 0 given in %spreg_replace_error.php on line %d +NULL + +-- Testing preg_replace() function with more than expected no. of arguments -- + +Warning: preg_replace() expects at most 5 parameters, 6 given in %spreg_replace_error.php on line %d +NULL + +-- Testing preg_replace() function with less than expected no. of arguments -- + +Warning: preg_replace() expects at least 3 parameters, 2 given in %spreg_replace_error.php on line %d +NULL +Done +--UEXPECTF-- +*** Testing preg_replace() : error conditions *** + +-- Testing preg_replace() function with zero arguments -- + +Warning: preg_replace() expects at least 3 parameters, 0 given in %spreg_replace_error.php on line %d +NULL + +-- Testing preg_replace() function with more than expected no. of arguments -- + +Warning: preg_replace() expects at most 5 parameters, 6 given in %spreg_replace_error.php on line %d +NULL + +-- Testing preg_replace() function with less than expected no. of arguments -- + +Warning: preg_replace() expects at least 3 parameters, 2 given in %spreg_replace_error.php on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_replace_error1.phpt b/ext/pcre/tests/preg_replace_error1.phpt new file mode 100644 index 0000000000..0e1db5e61f --- /dev/null +++ b/ext/pcre/tests/preg_replace_error1.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test preg_replace() function : error - bad regular expressions +--FILE-- + +--EXPECTF-- +*** Testing preg_replace() : error conditions*** + +Arg value is abcdef + +Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in %spreg_replace_error1.php on line %d +NULL + +Arg value is /[a-zA-Z] + +Warning: preg_replace(): No ending delimiter '/' found in %spreg_replace_error1.php on line %d +NULL + +Arg value is [a-zA-Z]/ + +Warning: preg_replace(): Unknown modifier '/' in %spreg_replace_error1.php on line %d +NULL + +Arg value is /[a-zA-Z]/F + +Warning: preg_replace(): Unknown modifier 'F' in %spreg_replace_error1.php on line %d +NULL + +Arg value is Array +string(1) "a" + +Arg value is /[a-zA-Z]/ +string(1) "1" + +Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error1.php on line %d + + +--UEXPECTF-- +*** Testing preg_replace() : error conditions*** + +Arg value is abcdef + +Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in %spreg_replace_error1.php on line %d +NULL + +Arg value is /[a-zA-Z] + +Warning: preg_replace(): No ending delimiter '/' found in %spreg_replace_error1.php on line %d +NULL + +Arg value is [a-zA-Z]/ + +Warning: preg_replace(): Unknown modifier '/' in %spreg_replace_error1.php on line %d +NULL + +Arg value is /[a-zA-Z]/F + +Warning: preg_replace(): Unknown modifier 'F' in %spreg_replace_error1.php on line %d +NULL + +Arg value is Array +unicode(1) "a" + +Arg value is /[a-zA-Z]/ +unicode(1) "1" + +Catchable fatal error: Object of class stdClass could not be converted to binary string in %spreg_replace_error1.php on line %d \ No newline at end of file diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt new file mode 100644 index 0000000000..739d8a93b7 --- /dev/null +++ b/ext/pcre/tests/preg_replace_error2.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test preg_replace() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_replace() : error conditions *** + +Arg value is: this is a string +string(64) "this is a stringthis is a stringthis is a stringthis is a string" + +Arg value is: Array + +Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d +bool(false) + +Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error2.php on line %d + + +--UEXPECTF-- +*** Testing preg_replace() : error conditions *** + +Arg value is: this is a string +unicode(64) "this is a stringthis is a stringthis is a stringthis is a string" + +Arg value is: Array + +Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d +bool(false) + +Catchable fatal error: Object of class stdClass could not be converted to binary string in %spreg_replace_error2.php on line %d \ No newline at end of file diff --git a/ext/pcre/tests/preg_replace_variation1.phpt b/ext/pcre/tests/preg_replace_variation1.phpt new file mode 100644 index 0000000000..ac79e0bfaf --- /dev/null +++ b/ext/pcre/tests/preg_replace_variation1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test preg_replace() function : variation both arguments are arrays +--FILE-- + +--EXPECTF-- +This test a string. It contains numbers *0 to 9* test well test parentheses and some other things* diff --git a/ext/pcre/tests/preg_split_basic.phpt b/ext/pcre/tests/preg_split_basic.phpt new file mode 100644 index 0000000000..75f5beeddc --- /dev/null +++ b/ext/pcre/tests/preg_split_basic.phpt @@ -0,0 +1,135 @@ +--TEST-- +Test preg_split() function : basic functionality +--INI-- +--FILE-- + +--EXPECT-- +array(7) { + [0]=> + string(14) "this is a_list" + [1]=> + string(7) " value1" + [2]=> + string(7) " Test__" + [3]=> + string(7) " string" + [4]=> + string(6) " Hello" + [5]=> + string(8) " world!_" + [6]=> + string(11) "parentheses" +} +array(2) { + [0]=> + string(14) "this is a_list" + [1]=> + string(28) " Hello, world!_(parentheses)" +} +array(4) { + [0]=> + string(54) "this is a_list: value1, Test__, string; Hello, world!_" + [1]=> + string(1) "(" + [2]=> + string(11) "parentheses" + [3]=> + string(1) ")" +} +array(1) { + [0]=> + string(67) "this is a_list: value1, Test__, string; Hello, world!_(parentheses)" +} +array(10) { + [0]=> + string(1) " " + [1]=> + string(1) " " + [2]=> + string(2) ": " + [3]=> + string(2) ", " + [4]=> + string(2) ", " + [5]=> + string(2) "; " + [6]=> + string(2) ", " + [7]=> + string(1) "!" + [8]=> + string(1) "(" + [9]=> + string(1) ")" +} +--UEXPECTF-- +array(7) { + [0]=> + unicode(14) "this is a_list" + [1]=> + unicode(7) " value1" + [2]=> + unicode(7) " Test__" + [3]=> + unicode(7) " string" + [4]=> + unicode(6) " Hello" + [5]=> + unicode(8) " world!_" + [6]=> + unicode(11) "parentheses" +} +array(2) { + [0]=> + unicode(14) "this is a_list" + [1]=> + unicode(28) " Hello, world!_(parentheses)" +} +array(4) { + [0]=> + unicode(54) "this is a_list: value1, Test__, string; Hello, world!_" + [1]=> + unicode(1) "(" + [2]=> + unicode(11) "parentheses" + [3]=> + unicode(1) ")" +} +array(1) { + [0]=> + unicode(67) "this is a_list: value1, Test__, string; Hello, world!_(parentheses)" +} +array(10) { + [0]=> + unicode(1) " " + [1]=> + unicode(1) " " + [2]=> + unicode(2) ": " + [3]=> + unicode(2) ", " + [4]=> + unicode(2) ", " + [5]=> + unicode(2) "; " + [6]=> + unicode(2) ", " + [7]=> + unicode(1) "!" + [8]=> + unicode(1) "(" + [9]=> + unicode(1) ")" +} \ No newline at end of file diff --git a/ext/pcre/tests/preg_split_error.phpt b/ext/pcre/tests/preg_split_error.phpt new file mode 100644 index 0000000000..960b286c91 --- /dev/null +++ b/ext/pcre/tests/preg_split_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test preg_split() function : error conditions - incorrect number of parameters +--FILE-- + +--EXPECTF-- +*** Testing preg_split() : error conditions *** + +-- Testing preg_split() function with Zero arguments -- + +Warning: preg_split() expects at least 2 parameters, 0 given in %spreg_split_error.php on line %d +bool(false) + +-- Testing preg_split() function with more than expected no. of arguments -- + +Warning: preg_split() expects at most 4 parameters, 5 given in %spreg_split_error.php on line %d +bool(false) + +-- Testing preg_split() function with less than expected no. of arguments -- + +Warning: preg_split() expects at least 2 parameters, 1 given in %spreg_split_error.php on line %d +bool(false) +Done \ No newline at end of file diff --git a/ext/pcre/tests/preg_split_error1.phpt b/ext/pcre/tests/preg_split_error1.phpt new file mode 100644 index 0000000000..94c4ee522e --- /dev/null +++ b/ext/pcre/tests/preg_split_error1.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test preg_split() function : error conditions - bad regular expressions +--FILE-- + +--EXPECTF-- +*** Testing preg_split() : error conditions *** + +Arg value is abcdef + +Warning: preg_split(): Delimiter must not be alphanumeric or backslash in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_split() expects parameter 1 to be string (Unicode or binary), array given in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/ +array(3) { + [0]=> + string(4) "1 2 " + [1]=> + string(5) " 3 4 " + [2]=> + string(4) " 5 6" +} + +Warning: preg_split() expects parameter 1 to be string (Unicode or binary), object given in %spreg_split_error1.php on line %d +bool(false) +--UEXPECTF-- +*** Testing preg_split() : error conditions *** + +Arg value is abcdef + +Warning: preg_split(): Delimiter must not be alphanumeric or backslash in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z] + +Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d +bool(false) + +Arg value is [a-zA-Z]/ + +Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/F + +Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d +bool(false) + +Arg value is Array + +Warning: preg_split() expects parameter 1 to be string (Unicode or binary), array given in %spreg_split_error1.php on line %d +bool(false) + +Arg value is /[a-zA-Z]/ +array(3) { + [0]=> + unicode(4) "1 2 " + [1]=> + unicode(5) " 3 4 " + [2]=> + unicode(4) " 5 6" +} + +Warning: preg_split() expects parameter 1 to be string (Unicode or binary), object given in %spreg_split_error1.php on line %d +bool(false) diff --git a/ext/pcre/tests/preg_split_error2.phpt b/ext/pcre/tests/preg_split_error2.phpt new file mode 100644 index 0000000000..d4e7f1bf64 --- /dev/null +++ b/ext/pcre/tests/preg_split_error2.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test preg_split() function : error conditions - wrong arg types +--FILE-- + +--EXPECTF-- +*** Testing preg_split() : error conditions *** + +Arg value is: Array + +Warning: preg_split() expects parameter 2 to be string (Unicode or binary), array given in %spreg_split_error2.php on line %d +bool(false) + +Warning: preg_split() expects parameter 2 to be string (Unicode or binary), object given in %spreg_split_error2.php on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing preg_split() : error conditions *** + +Arg value is: Array + +Warning: preg_split() expects parameter 2 to be string (Unicode or binary), array given in %spreg_split_error2.php on line %d +bool(false) + +Warning: preg_split() expects parameter 2 to be string (Unicode or binary), object given in %spreg_split_error2.php on line %d +bool(false) +Done