diff options
author | George Peter Banyard <girgias@php.net> | 2019-11-18 23:40:02 +0100 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2019-12-05 14:22:54 +0100 |
commit | 5fbd49f9abc058ea3040ce00b2225e4cc46ce650 (patch) | |
tree | bc360e1afe2a91c149bcc55174fcb521a97a1bc7 /ext/standard/tests/strings | |
parent | 73730eebca0fa765fb8df5806a48d0ce268940a8 (diff) | |
download | php-git-5fbd49f9abc058ea3040ce00b2225e4cc46ce650.tar.gz |
Convert Errors to ValueErrors
Closes GH-4930
Diffstat (limited to 'ext/standard/tests/strings')
20 files changed, 40 insertions, 73 deletions
diff --git a/ext/standard/tests/strings/bug33605.phpt b/ext/standard/tests/strings/bug33605.phpt index b3cb2ece95..dd937851ca 100644 --- a/ext/standard/tests/strings/bug33605.phpt +++ b/ext/standard/tests/strings/bug33605.phpt @@ -4,10 +4,10 @@ Bug #33605 (substr_compare crashes) <?php try { substr_compare("aa", "a", -99999999, -1, 0); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage(); } ?> ---EXPECTF-- +--EXPECT-- The length must be greater than or equal to zero diff --git a/ext/standard/tests/strings/chunk_split_variation5.phpt b/ext/standard/tests/strings/chunk_split_variation5.phpt Binary files differindex bea49d24b4..bfcaa54e26 100644 --- a/ext/standard/tests/strings/chunk_split_variation5.phpt +++ b/ext/standard/tests/strings/chunk_split_variation5.phpt diff --git a/ext/standard/tests/strings/chunk_split_variation8.phpt b/ext/standard/tests/strings/chunk_split_variation8.phpt index 15c224962e..74b41ede03 100644 --- a/ext/standard/tests/strings/chunk_split_variation8.phpt +++ b/ext/standard/tests/strings/chunk_split_variation8.phpt @@ -50,14 +50,13 @@ for($count = 0; $count < count($values); $count++) { var_dump( chunk_split($heredoc_str, $values[$count], $ending) ); } catch (TypeError $e) { echo $e->getMessage(), "\n"; - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } -echo "Done" ?> ---EXPECTF-- +--EXPECT-- *** Testing chunk_split() : different 'chunklen' with heredoc 'str' *** -- Iteration 1 -- Chunk length should be greater than zero @@ -87,4 +86,3 @@ chunk_split():::" chunk_split() expects parameter 2 to be int, float given -- Iteration 8 -- Chunk length should be greater than zero -Done diff --git a/ext/standard/tests/strings/dirname_error.phpt b/ext/standard/tests/strings/dirname_error.phpt index daf4e2cb0a..99d0f28807 100644 --- a/ext/standard/tests/strings/dirname_error.phpt +++ b/ext/standard/tests/strings/dirname_error.phpt @@ -10,13 +10,11 @@ echo "*** Testing error conditions ***\n"; // Bad arg try { dirname("/var/tmp/bar.gz", 0); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } -echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- *** Testing error conditions *** Invalid argument, levels must be >= 1 -Done diff --git a/ext/standard/tests/strings/dirname_multi.phpt b/ext/standard/tests/strings/dirname_multi.phpt index f95bf16d2a..eb29de39a2 100644 --- a/ext/standard/tests/strings/dirname_multi.phpt +++ b/ext/standard/tests/strings/dirname_multi.phpt @@ -13,18 +13,16 @@ if((substr(PHP_OS, 0, 3) == "WIN")) for ($i=0 ; $i<5 ; $i++) { try { var_dump(dirname("/foo/bar/baz", $i)); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } var_dump(dirname("/foo/bar/baz", PHP_INT_MAX)); ?> -Done ---EXPECTF-- +--EXPECT-- Invalid argument, levels must be >= 1 string(8) "/foo/bar" string(4) "/foo" string(1) "/" string(1) "/" string(1) "/" -Done diff --git a/ext/standard/tests/strings/dirname_multi_win.phpt b/ext/standard/tests/strings/dirname_multi_win.phpt index 9dc0c05c59..d63d5e7950 100644 --- a/ext/standard/tests/strings/dirname_multi_win.phpt +++ b/ext/standard/tests/strings/dirname_multi_win.phpt @@ -14,7 +14,7 @@ if((substr(PHP_OS, 0, 3) != "WIN")) for ($i=0 ; $i<5 ; $i++) { try { var_dump(dirname("/foo/bar/baz", $i)); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } @@ -23,7 +23,6 @@ var_dump(dirname("/foo/bar/baz", PHP_INT_MAX)); var_dump(dirname("g:/foo/bar/baz", PHP_INT_MAX)); var_dump(dirname("g:foo/bar/baz", PHP_INT_MAX)); ?> -Done --EXPECT-- Invalid argument, levels must be >= 1 string(8) "/foo/bar" @@ -33,4 +32,3 @@ string(1) "\" string(1) "\" string(3) "g:\" string(3) "g:." -Done diff --git a/ext/standard/tests/strings/explode.phpt b/ext/standard/tests/strings/explode.phpt index 8fa3b62079..8375364175 100644 --- a/ext/standard/tests/strings/explode.phpt +++ b/ext/standard/tests/strings/explode.phpt @@ -14,17 +14,17 @@ echo "\n"; try { var_dump(explode("", "")); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump(explode("", NULL)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump(explode(NULL, "")); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } @@ -33,7 +33,7 @@ var_dump(explode("a", "a")); var_dump(explode("a", NULL)); try { var_dump(explode(NULL, "a")); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } var_dump(explode("abc", "acb")); diff --git a/ext/standard/tests/strings/explode1.phpt b/ext/standard/tests/strings/explode1.phpt index 4d692e49e8..191ab1207c 100644 --- a/ext/standard/tests/strings/explode1.phpt +++ b/ext/standard/tests/strings/explode1.phpt @@ -36,22 +36,22 @@ foreach($delimiters as $delimiter) { try { var_dump( explode($delimiter, $string, -1) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump( explode($delimiter, $string, 0) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump( explode($delimiter, $string, 1) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump( explode($delimiter, $string, 2) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } $counter++; @@ -94,9 +94,8 @@ class string1 { $obj = new string1; var_dump( explode("b", $obj) ); -echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- *** Testing explode() for basic operations *** -- Iteration 1 -- Empty delimiter @@ -486,4 +485,3 @@ array(2) { [1]=> string(4) "ject" } -Done diff --git a/ext/standard/tests/strings/str_pad.phpt b/ext/standard/tests/strings/str_pad.phpt index a4f60bfa6a..42b6383a5e 100644 --- a/ext/standard/tests/strings/str_pad.phpt +++ b/ext/standard/tests/strings/str_pad.phpt @@ -67,13 +67,13 @@ echo "\n--- padding string as null ---\n"; try { str_pad($input_string, 12, NULL); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { str_pad($input_string, 12, ""); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } @@ -81,11 +81,10 @@ try { try { str_pad($input_string, $pad_length, "+", 15); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } -echo "Done\n"; ?> --EXPECT-- #### Basic operations #### @@ -343,4 +342,3 @@ string(16) "\t\variation\t\t" Padding string cannot be empty Padding string cannot be empty Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH -Done diff --git a/ext/standard/tests/strings/str_repeat.phpt b/ext/standard/tests/strings/str_repeat.phpt Binary files differindex 6e5f0cf68e..4751dc783f 100644 --- a/ext/standard/tests/strings/str_repeat.phpt +++ b/ext/standard/tests/strings/str_repeat.phpt diff --git a/ext/standard/tests/strings/str_split_variation6.phpt b/ext/standard/tests/strings/str_split_variation6.phpt index 111eb11858..2d73a06d10 100644 --- a/ext/standard/tests/strings/str_split_variation6.phpt +++ b/ext/standard/tests/strings/str_split_variation6.phpt @@ -39,11 +39,10 @@ for($count = 0; $count < count($values); $count++) { try { var_dump( str_split($str, $values[$count]) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } -echo "Done" ?> --EXPECT-- *** Testing str_split() : different integer values for 'split_length' *** @@ -157,4 +156,3 @@ array(1) { } -- Iteration 7 -- The length of each segment must be greater than zero -Done diff --git a/ext/standard/tests/strings/str_split_variation6_64bit.phpt b/ext/standard/tests/strings/str_split_variation6_64bit.phpt index e6893e9263..f9cd29cef3 100644 --- a/ext/standard/tests/strings/str_split_variation6_64bit.phpt +++ b/ext/standard/tests/strings/str_split_variation6_64bit.phpt @@ -18,7 +18,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); * passing different integer values for 'split_length' argument to str_split() */ -echo "*** Testing str_split() : different intger values for 'split_length' ***\n"; +echo "*** Testing str_split() : different integer values for 'split_length' ***\n"; //Initialise variables $str = 'This is a string with 123 & escape char \t'; @@ -39,14 +39,13 @@ for($count = 0; $count < count($values); $count++) { echo "-- Iteration ".($count + 1)." --\n"; try { var_dump( str_split($str, $values[$count]) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } -echo "Done" ?> --EXPECT-- -*** Testing str_split() : different intger values for 'split_length' *** +*** Testing str_split() : different integer values for 'split_length' *** -- Iteration 1 -- The length of each segment must be greater than zero -- Iteration 2 -- @@ -162,4 +161,3 @@ array(1) { } -- Iteration 8 -- The length of each segment must be greater than zero -Done diff --git a/ext/standard/tests/strings/str_split_variation7.phpt b/ext/standard/tests/strings/str_split_variation7.phpt index a810dd7ecb..4d28b765ac 100644 --- a/ext/standard/tests/strings/str_split_variation7.phpt +++ b/ext/standard/tests/strings/str_split_variation7.phpt @@ -41,11 +41,10 @@ for($count = 0; $count < count($values); $count++) { try { var_dump( str_split($str, $values[$count]) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } -echo "Done" ?> --EXPECT-- *** Testing str_split() : different integer values for 'split_length' with heredoc 'str' *** @@ -135,4 +134,3 @@ array(1) { } -- Iteration 7 -- The length of each segment must be greater than zero -Done diff --git a/ext/standard/tests/strings/str_split_variation7_64bit.phpt b/ext/standard/tests/strings/str_split_variation7_64bit.phpt index 1a1980028a..d1771e6e2d 100644 --- a/ext/standard/tests/strings/str_split_variation7_64bit.phpt +++ b/ext/standard/tests/strings/str_split_variation7_64bit.phpt @@ -41,11 +41,10 @@ for($count = 0; $count < count($values); $count++) { echo "-- Iteration ".($count + 1)." --\n"; try { var_dump( str_split($str, $values[$count]) ); - } catch (\Error $e) { + } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } } -echo "Done" ?> --EXPECT-- *** Testing str_split() : different integer values for 'split_length' with heredoc 'str' *** @@ -140,4 +139,3 @@ array(1) { } -- Iteration 8 -- The length of each segment must be greater than zero -Done diff --git a/ext/standard/tests/strings/str_word_count.phpt b/ext/standard/tests/strings/str_word_count.phpt index 375f26dee0..480ee5b64a 100644 --- a/ext/standard/tests/strings/str_word_count.phpt +++ b/ext/standard/tests/strings/str_word_count.phpt @@ -11,25 +11,25 @@ var_dump(str_word_count($str)); try { var_dump(str_word_count($str, 3)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump(str_word_count($str, 123)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump(str_word_count($str, -1)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump(str_word_count($str, 999999999)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } diff --git a/ext/standard/tests/strings/str_word_count1.phpt b/ext/standard/tests/strings/str_word_count1.phpt index 6ce8c38f22..9eab1afcbc 100644 --- a/ext/standard/tests/strings/str_word_count1.phpt +++ b/ext/standard/tests/strings/str_word_count1.phpt @@ -7,20 +7,18 @@ var_dump(str_word_count("")); try { var_dump(str_word_count("", -1)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { var_dump(str_word_count("", -1, $a)); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } var_dump($a); ?> - -DONE --EXPECTF-- int(0) Invalid format value -1 @@ -30,5 +28,3 @@ Invalid format value -1 Warning: Undefined variable: a in %s on line %d NULL - -DONE diff --git a/ext/standard/tests/strings/substr_compare.phpt b/ext/standard/tests/strings/substr_compare.phpt index 6a0bca4336..52de7fe394 100644 --- a/ext/standard/tests/strings/substr_compare.phpt +++ b/ext/standard/tests/strings/substr_compare.phpt @@ -17,14 +17,12 @@ echo "Test\n"; try { substr_compare("abcde", "abc", 0, -1); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } var_dump(substr_compare("abcde", "abc", -1, NULL, -5) > 0); - -echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- bool(true) bool(true) int(0) @@ -38,4 +36,3 @@ int(0) Test The length must be greater than or equal to zero bool(true) -Done diff --git a/ext/standard/tests/strings/substr_count_basic.phpt b/ext/standard/tests/strings/substr_count_basic.phpt index a6d715ed67..df77bfd721 100644 --- a/ext/standard/tests/strings/substr_count_basic.phpt +++ b/ext/standard/tests/strings/substr_count_basic.phpt @@ -6,12 +6,12 @@ Test substr_count() function (basic) echo "***Testing basic operations ***\n"; try { substr_count("", ""); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { substr_count("a", ""); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } var_dump(substr_count("", "a")); @@ -31,8 +31,6 @@ var_dump(substr_count($a, "bca", -200, null)); var_dump(substr_count($a, "bca", -200, 50)); var_dump(substr_count($a, "bca", -200, -50)); -echo "Done\n"; - ?> --EXPECT-- ***Testing basic operations *** @@ -50,4 +48,3 @@ int(40) int(40) int(10) int(30) -Done diff --git a/ext/standard/tests/strings/wordwrap.phpt b/ext/standard/tests/strings/wordwrap.phpt index 8c2b08f046..0563b2e77f 100644 --- a/ext/standard/tests/strings/wordwrap.phpt +++ b/ext/standard/tests/strings/wordwrap.phpt @@ -35,7 +35,7 @@ echo "\n"; try { wordwrap(chr(0), 0, ""); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } --EXPECT-- diff --git a/ext/standard/tests/strings/wordwrap_error.phpt b/ext/standard/tests/strings/wordwrap_error.phpt index f0fa80f63d..af0f8eb61b 100644 --- a/ext/standard/tests/strings/wordwrap_error.phpt +++ b/ext/standard/tests/strings/wordwrap_error.phpt @@ -29,7 +29,7 @@ $cut = true; try { wordwrap($str, $width, $break, $cut); -} catch (\Error $e) { +} catch (\ValueError $e) { echo $e->getMessage() . "\n"; } @@ -44,10 +44,8 @@ echo "-- width = -10 & cut = true --\n"; $width = -10; $cut = true; var_dump( wordwrap($str, $width, $break, $cut) ); - -echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- *** Testing wordwrap() : error conditions *** -- Testing wordwrap() function with negative/zero value for width argument -- @@ -59,4 +57,3 @@ Can't force cut when width is zero string(39) "testing<br />\nwordwrap<br />\nfunction" -- width = -10 & cut = true -- string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn" -Done |