Skip to content

Commit 30bf210

Browse files
committed
general functions test fixes
1 parent 35e092d commit 30bf210

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+134
-706
lines changed
42 Bytes
Binary file not shown.

ext/standard/tests/strings/bug54322.phpt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
Bug #54322: Null pointer deref in get_html_translation_table due to information loss in long-to-int conversion
33
--FILE--
44
<?php
5-
var_dump(
6-
get_html_translation_table(NAN, 0, "UTF-8") > 0
7-
);
8-
--EXPECTF--
9-
Warning: get_html_translation_table() expects parameter 1 to be int, float given in %s on line %d
10-
bool(false)
5+
try {
6+
var_dump(get_html_translation_table(NAN, 0, "UTF-8") > 0);
7+
} catch (TypeError $e) {
8+
echo $e->getMessage(), "\n";
9+
}
10+
?>
11+
--EXPECT--
12+
get_html_translation_table() expects parameter 1 to be int, float given

ext/standard/tests/strings/chr_error.phpt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,28 @@ Test chr() function : error conditions
1111
echo "*** Testing chr() : error conditions ***\n";
1212

1313
echo "\n-- Testing chr() function with no arguments --\n";
14-
var_dump( chr() );
14+
try {
15+
var_dump( chr() );
16+
} catch (TypeError $e) {
17+
echo $e->getMessage(), "\n";
18+
}
1519

1620
echo "\n-- Testing chr() function with more than expected no. of arguments --\n";
1721
$extra_arg = 10;
18-
var_dump( chr(72, $extra_arg) );
22+
try {
23+
var_dump( chr(72, $extra_arg) );
24+
} catch (TypeError $e) {
25+
echo $e->getMessage(), "\n";
26+
}
1927

2028
?>
2129
===DONE===
2230
--EXPECTF--
2331
*** Testing chr() : error conditions ***
2432

2533
-- Testing chr() function with no arguments --
26-
27-
Warning: Wrong parameter count for chr() in %s on line %d
28-
NULL
34+
Wrong parameter count for chr()
2935

3036
-- Testing chr() function with more than expected no. of arguments --
31-
32-
Warning: Wrong parameter count for chr() in %s on line %d
33-
NULL
37+
Wrong parameter count for chr()
3438
===DONE===
-717 Bytes
Binary file not shown.
Binary file not shown.

ext/standard/tests/strings/chunk_split_variation8.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ $values = array (
4646
// loop through each element of values for 'chunklen'
4747
for($count = 0; $count < count($values); $count++) {
4848
echo "-- Iteration ".($count+1). " --\n";
49-
var_dump( chunk_split($heredoc_str, $values[$count], $ending) );
49+
try {
50+
var_dump( chunk_split($heredoc_str, $values[$count], $ending) );
51+
} catch (TypeError $e) {
52+
echo $e->getMessage(), "\n";
53+
}
5054
}
5155

5256
echo "Done"
@@ -82,9 +86,7 @@ string(129) "This's heredoc string with and
8286
It has _speci@l ch@r$ 2222 !!!Now \k as escape char to test
8387
chunk_split():::"
8488
-- Iteration 7 --
85-
86-
Warning: chunk_split() expects parameter 2 to be int, float given in %s on line %d
87-
NULL
89+
chunk_split() expects parameter 2 to be int, float given
8890
-- Iteration 8 --
8991

9092
Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d

ext/standard/tests/strings/convert_cyr_string.phpt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ basic convert_cyr_string() tests
33
--FILE--
44
<?php
55

6-
var_dump(convert_cyr_string());
7-
var_dump(convert_cyr_string(""));
8-
var_dump(convert_cyr_string("", ""));
96
var_dump(convert_cyr_string("", "", ""));
107
var_dump(convert_cyr_string(array(), array(), array()));
118

@@ -20,15 +17,6 @@ var_dump(convert_cyr_string("", "d", "i"));
2017
echo "Done\n";
2118
?>
2219
--EXPECTF--
23-
Warning: convert_cyr_string() expects exactly 3 parameters, 0 given in %s on line %d
24-
NULL
25-
26-
Warning: convert_cyr_string() expects exactly 3 parameters, 1 given in %s on line %d
27-
NULL
28-
29-
Warning: convert_cyr_string() expects exactly 3 parameters, 2 given in %s on line %d
30-
NULL
31-
3220
Warning: convert_cyr_string(): Unknown source charset: in %s on line %d
3321

3422
Warning: convert_cyr_string(): Unknown destination charset: in %s on line %d

ext/standard/tests/strings/convert_cyr_string_error.phpt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ $extra_arg = 10;
1515

1616
echo "*** Testing convert_cyr_string() : error conditions ***\n";
1717

18-
echo "\n-- Testing convert_cyr_string() function with no arguments --\n";
19-
var_dump( convert_cyr_string() );
20-
21-
echo "\n-- Testing convert_cyr_string() function with no 'to' character set --\n";
22-
var_dump( convert_cyr_string($str, $from) );
23-
24-
echo "\n-- Testing convert_cyr_string() function with more than expected no. of arguments --\n";
25-
var_dump( convert_cyr_string($str, $from, $to, $extra_arg) );
26-
2718
echo "\n-- Testing convert_cyr_string() function with invalid 'from' character set --\n";
2819
var_dump(bin2hex( convert_cyr_string($str, "?", $to) ));
2920

@@ -38,21 +29,6 @@ var_dump(bin2hex( convert_cyr_string($str, ">", "?")) );
3829
--EXPECTF--
3930
*** Testing convert_cyr_string() : error conditions ***
4031

41-
-- Testing convert_cyr_string() function with no arguments --
42-
43-
Warning: convert_cyr_string() expects exactly 3 parameters, 0 given in %s on line %d
44-
NULL
45-
46-
-- Testing convert_cyr_string() function with no 'to' character set --
47-
48-
Warning: convert_cyr_string() expects exactly 3 parameters, 2 given in %s on line %d
49-
NULL
50-
51-
-- Testing convert_cyr_string() function with more than expected no. of arguments --
52-
53-
Warning: convert_cyr_string() expects exactly 3 parameters, 4 given in %s on line %d
54-
NULL
55-
5632
-- Testing convert_cyr_string() function with invalid 'from' character set --
5733

5834
Warning: convert_cyr_string(): Unknown source charset: ? in %s on line %d

ext/standard/tests/strings/crypt.phpt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ echo (CRYPT_MD5) ? ((crypt($str, $salt3) === $res_3) ? 'MD5' : 'MD5 - ERROR
1919
echo (CRYPT_BLOWFISH) ? ((crypt($str, $salt4) === $res_4) ? 'BLO' : 'BLO - ERROR') : 'BLO', "\n";
2020

2121
var_dump(crypt($str));
22-
var_dump(crypt());
23-
var_dump(crypt("", "", ""));
2422

2523
?>
2624
--EXPECTF--
@@ -31,9 +29,3 @@ BLO
3129

3230
Notice: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash. in %s on line %d
3331
string(%d) "%s"
34-
35-
Warning: crypt() expects at least 1 parameter, 0 given in %s on line %d
36-
NULL
37-
38-
Warning: crypt() expects at most 2 parameters, 3 given in %s on line %d
39-
NULL

ext/standard/tests/strings/dirname_error.phpt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,15 @@ Test dirname() function : error conditions
66
Description: Returns directory name component of path.
77
*/
88
echo "*** Testing error conditions ***\n";
9-
// zero arguments
10-
var_dump( dirname() );
119

1210
// Bad arg
1311
var_dump( dirname("/var/tmp/bar.gz", 0) );
1412

15-
// more than expected no. of arguments
16-
var_dump( dirname("/var/tmp/bar.gz", 1, ".gz") );
17-
1813
echo "Done\n";
1914
?>
2015
--EXPECTF--
2116
*** Testing error conditions ***
2217

23-
Warning: dirname() expects at least 1 parameter, 0 given in %s on line %d
24-
NULL
25-
2618
Warning: dirname(): Invalid argument, levels must be >= 1 in %s on line %d
2719
NULL
28-
29-
Warning: dirname() expects at most 2 parameters, 3 given in %s on line %d
30-
NULL
3120
Done

ext/standard/tests/strings/explode1.phpt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ class string1 {
7777
$obj = new string1;
7878
var_dump( explode("b", $obj) );
7979

80-
echo "\n*** Testing error conditions ***\n";
81-
/* checking for arguments <2 and >3 */
82-
var_dump( explode(":", "array1:array2:array3", -1, -33) );
83-
var_dump( explode(":") );
84-
8580
echo "Done\n";
8681
?>
8782
--EXPECTF--
@@ -499,11 +494,4 @@ array(2) {
499494
string(4) "ject"
500495
}
501496

502-
*** Testing error conditions ***
503-
504-
Warning: explode() expects at most 3 parameters, 4 given in %s on line %d
505-
NULL
506-
507-
Warning: explode() expects at least 2 parameters, 1 given in %s on line %d
508-
NULL
509497
Done

ext/standard/tests/strings/fprintf_error.phpt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,31 @@ Test fprintf() function (errors)
77
echo "*** Testing Error Conditions ***\n";
88

99
/* zero argument */
10-
var_dump( fprintf() );
10+
try {
11+
var_dump( fprintf() );
12+
} catch (TypeError $e) {
13+
echo $e->getMessage(), "\n";
14+
}
1115

1216
/* scalar argument */
13-
var_dump( fprintf(3) );
17+
try {
18+
var_dump( fprintf(3) );
19+
} catch (TypeError $e) {
20+
echo $e->getMessage(), "\n";
21+
}
1422

1523
/* NULL argument */
16-
var_dump( fprintf(NULL) );
24+
try {
25+
var_dump( fprintf(NULL) );
26+
} catch (TypeError $e) {
27+
echo $e->getMessage(), "\n";
28+
}
1729

1830
echo "Done\n";
1931
?>
2032
--EXPECTF--
2133
*** Testing Error Conditions ***
22-
23-
Warning: Wrong parameter count for fprintf() in %sfprintf_error.php on line %d
24-
NULL
25-
26-
Warning: Wrong parameter count for fprintf() in %sfprintf_error.php on line %d
27-
NULL
28-
29-
Warning: Wrong parameter count for fprintf() in %sfprintf_error.php on line %d
30-
NULL
34+
Wrong parameter count for fprintf()
35+
Wrong parameter count for fprintf()
36+
Wrong parameter count for fprintf()
3137
Done

ext/standard/tests/strings/highlight_file.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ allow_url_fopen=1
1313

1414
$filename = dirname(__FILE__)."/highlight_file.dat";
1515

16-
var_dump(highlight_file());
1716
var_dump(highlight_file($filename));
1817

1918
var_dump(highlight_file('data:,<?php echo "test"; ?>'));
@@ -37,9 +36,6 @@ var_dump(highlight_file($filename));
3736
echo "Done\n";
3837
?>
3938
--EXPECTF--
40-
Warning: highlight_file() expects at least 1 parameter, 0 given in %s on line %d
41-
bool(false)
42-
4339
Warning: highlight_file(%shighlight_file.dat): failed to open stream: No such file or directory in %s on line %d
4440

4541
Warning: highlight_file(): Failed opening '%shighlight_file.dat' for highlighting in %s on line %d

ext/standard/tests/strings/htmlentities24.phpt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ var_dump( htmlentities($str, ENT_QUOTES) );
3535
var_dump( htmlentities($str, ENT_NOQUOTES) );
3636
var_dump( htmlentities($str, ENT_COMPAT) );
3737

38-
echo "\n*** Testing error conditions ***\n";
39-
/* zero argument */
40-
var_dump( htmlentities() );
41-
/* arguments more than expected */
42-
var_dump( htmlentities("\x84\x91",ENT_QUOTES, 'cp1252', "test1") );
43-
4438
echo "Done\n";
4539
?>
4640
--EXPECTF--
@@ -320,10 +314,4 @@ string(36) "A 'quote' is &lt;b&gt;bold&lt;/b&gt;"
320314
string(46) "A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;"
321315
string(36) "A 'quote' is &lt;b&gt;bold&lt;/b&gt;"
322316
string(36) "A 'quote' is &lt;b&gt;bold&lt;/b&gt;"
323-
324-
*** Testing error conditions ***
325-
326-
Warning: htmlentities() expects at least 1 parameter, 0 given in %s on line %d
327-
NULL
328-
string(14) "&bdquo;&lsquo;"
329317
Done

ext/standard/tests/strings/htmlspecialchars.phpt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ var_dump( htmlspecialchars($str, ENT_QUOTES) );
3535
var_dump( htmlspecialchars($str, ENT_NOQUOTES) );
3636
var_dump( htmlspecialchars($str, ENT_COMPAT) );
3737

38-
echo "\n*** Testing error conditions ***\n";
39-
/* zero argument */
40-
var_dump( htmlspecialchars() );
41-
42-
/* giving arguments more than expected */
43-
var_dump( htmlspecialchars("<br>",ENT_QUOTES,'iso-8859-1', "test2") );
44-
4538
echo "Done\n"
4639
?>
4740
--EXPECTF--
@@ -321,10 +314,4 @@ string(36) "A 'quote' is &lt;b&gt;bold&lt;/b&gt;"
321314
string(46) "A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;"
322315
string(36) "A 'quote' is &lt;b&gt;bold&lt;/b&gt;"
323316
string(36) "A 'quote' is &lt;b&gt;bold&lt;/b&gt;"
324-
325-
*** Testing error conditions ***
326-
327-
Warning: htmlspecialchars() expects at least 1 parameter, 0 given in %s on line %d
328-
NULL
329-
string(10) "&lt;br&gt;"
330317
Done
-279 Bytes
Binary file not shown.

ext/standard/tests/strings/join_error.phpt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ Test join() function: error conditions
1010

1111
echo "*** Testing join() : error conditions ***\n";
1212

13-
// Zero argument
14-
echo "\n-- Testing join() function with Zero arguments --\n";
15-
var_dump( join() );
16-
17-
// More than expected number of arguments
18-
echo "\n-- Testing join() function with more than expected no. of arguments --\n";
19-
$glue = 'string_val';
20-
$pieces = array(1, 2);
21-
$extra_arg = 10;
22-
23-
var_dump( join($glue, $pieces, $extra_arg) );
24-
2513
// Less than expected number of arguments
2614
echo "\n-- Testing join() with less than expected no. of arguments --\n";
2715
$glue = 'string_val';
@@ -33,16 +21,6 @@ echo "Done\n";
3321
--EXPECTF--
3422
*** Testing join() : error conditions ***
3523

36-
-- Testing join() function with Zero arguments --
37-
38-
Warning: join() expects at least 1 parameter, 0 given in %s on line %d
39-
NULL
40-
41-
-- Testing join() function with more than expected no. of arguments --
42-
43-
Warning: join() expects at most 2 parameters, 3 given in %s on line %d
44-
NULL
45-
4624
-- Testing join() with less than expected no. of arguments --
4725

4826
Warning: join(): Argument must be an array in %s on line %d
-423 Bytes
Binary file not shown.

ext/standard/tests/strings/levenshtein.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ $n += test_me("gt maxlength2", -1, "A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijkl
6363

6464
echo ($n==0)?"all passed\n":"$n failed\n";
6565

66-
var_dump(levenshtein(array(), array()));
6766
var_dump(levenshtein("", "", -1, -1, -1));
6867
var_dump(levenshtein("", "", 10, 10, 10));
6968
var_dump(levenshtein(""));
@@ -76,9 +75,6 @@ Warning: levenshtein(): Argument string(s) too long in %s on line %d
7675

7776
Warning: levenshtein(): Argument string(s) too long in %s on line %d
7877
all passed
79-
80-
Warning: levenshtein() expects parameter 1 to be string, array given in %s on line %d
81-
NULL
8278
int(0)
8379
int(0)
8480

0 commit comments

Comments
 (0)