Skip to content

Commit 8258eee

Browse files
committed
Start on test fixes
1 parent 506341b commit 8258eee

40 files changed

+178
-294
lines changed

Zend/tests/011.phpt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class bar extends foo {
2323
}
2424
}
2525

26-
var_dump(property_exists());
27-
var_dump(property_exists(""));
2826
var_dump(property_exists("foo","pp1"));
2927
var_dump(property_exists("foo","pp2"));
3028
var_dump(property_exists("foo","pp3"));
@@ -53,11 +51,6 @@ $bar->test();
5351
echo "Done\n";
5452
?>
5553
--EXPECTF--
56-
Warning: property_exists() expects exactly 2 parameters, 0 given in %s on line %d
57-
NULL
58-
59-
Warning: property_exists() expects exactly 2 parameters, 1 given in %s on line %d
60-
NULL
6154
bool(true)
6255
bool(true)
6356
bool(true)

Zend/tests/012.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ class_exists() tests
66
class foo {
77
}
88

9-
var_dump(class_exists());
109
var_dump(class_exists("qwerty"));
1110
var_dump(class_exists(""));
12-
var_dump(class_exists(array()));
1311
var_dump(class_exists("test", false));
1412
var_dump(class_exists("foo", false));
1513
var_dump(class_exists("foo"));
@@ -18,14 +16,9 @@ var_dump(class_exists("stdClass"));
1816

1917
echo "Done\n";
2018
?>
21-
--EXPECTF--
22-
Warning: class_exists() expects at least 1 parameter, 0 given in %s on line %d
23-
NULL
19+
--EXPECT--
2420
bool(false)
2521
bool(false)
26-
27-
Warning: class_exists() expects parameter 1 to be string, array given in %s on line %d
28-
NULL
2922
bool(false)
3023
bool(true)
3124
bool(true)

Zend/tests/013.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ interface_exists() tests
66
interface foo {
77
}
88

9-
var_dump(interface_exists());
109
var_dump(interface_exists("qwerty"));
1110
var_dump(interface_exists(""));
12-
var_dump(interface_exists(array()));
1311
var_dump(interface_exists("test", false));
1412
var_dump(interface_exists("foo", false));
1513
var_dump(interface_exists("foo"));
@@ -18,14 +16,9 @@ var_dump(interface_exists("stdClass"));
1816

1917
echo "Done\n";
2018
?>
21-
--EXPECTF--
22-
Warning: interface_exists() expects at least 1 parameter, 0 given in %s on line %d
23-
NULL
19+
--EXPECT--
2420
bool(false)
2521
bool(false)
26-
27-
Warning: interface_exists() expects parameter 1 to be string, array given in %s on line %d
28-
NULL
2922
bool(false)
3023
bool(true)
3124
bool(true)

Zend/tests/014.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ var_dump(get_included_files());
88
include(dirname(__FILE__)."/014.inc");
99
var_dump(get_included_files());
1010

11-
var_dump(get_included_files(1,1));
12-
1311
include_once(dirname(__FILE__)."/014.inc");
1412
var_dump(get_included_files());
1513

16-
var_dump(get_included_files(1));
17-
1814
include(dirname(__FILE__)."/014.inc");
1915
var_dump(get_included_files());
2016

@@ -31,18 +27,12 @@ array(2) {
3127
[1]=>
3228
string(%d) "%s"
3329
}
34-
35-
Warning: get_included_files() expects exactly 0 parameters, 2 given in %s on line %d
36-
NULL
3730
array(2) {
3831
[0]=>
3932
string(%d) "%s"
4033
[1]=>
4134
string(%d) "%s"
4235
}
43-
44-
Warning: get_included_files() expects exactly 0 parameters, 1 given in %s on line %d
45-
NULL
4636
array(2) {
4737
[0]=>
4838
string(%d) "%s"

Zend/tests/015.phpt

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

6-
var_dump(trigger_error());
76
var_dump(trigger_error("error"));
8-
var_dump(trigger_error(array()));
97
var_dump(trigger_error("error", -1));
108
var_dump(trigger_error("error", 0));
119
var_dump(trigger_error("error", E_USER_WARNING));
@@ -14,15 +12,9 @@ var_dump(trigger_error("error", E_USER_DEPRECATED));
1412
echo "Done\n";
1513
?>
1614
--EXPECTF--
17-
Warning: trigger_error() expects at least 1 parameter, 0 given in %s on line %d
18-
NULL
19-
2015
Notice: error in %s on line %d
2116
bool(true)
2217

23-
Warning: trigger_error() expects parameter 1 to be string, array given in %s on line %d
24-
NULL
25-
2618
Warning: Invalid error type specified in %s on line %d
2719
bool(false)
2820

Zend/tests/017.phpt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ builtin functions tests
33
--FILE--
44
<?php
55

6-
var_dump(get_resource_type());
7-
var_dump(get_resource_type(""));
86
$fp = fopen(__FILE__, "r");
97
var_dump(get_resource_type($fp));
108
fclose($fp);
@@ -14,11 +12,9 @@ var_dump(gettype(get_loaded_extensions()));
1412
var_dump(count(get_loaded_extensions()));
1513
var_dump(gettype(get_loaded_extensions(true)));
1614
var_dump(count(get_loaded_extensions(true)));
17-
var_dump(get_loaded_extensions(true, true));
1815

1916
define("USER_CONSTANT", "test");
2017

21-
var_dump(get_defined_constants(true, true));
2218
var_dump(gettype(get_defined_constants(true)));
2319
var_dump(gettype(get_defined_constants()));
2420
var_dump(count(get_defined_constants()));
@@ -29,11 +25,9 @@ function test () {
2925
var_dump(gettype(get_defined_functions()));
3026
var_dump(count(get_defined_functions()));
3127

32-
var_dump(get_declared_interfaces(true));
3328
var_dump(gettype(get_declared_interfaces()));
3429
var_dump(count(get_declared_interfaces()));
3530

36-
var_dump(get_extension_funcs());
3731
var_dump(get_extension_funcs(true));
3832
var_dump(gettype(get_extension_funcs("standard")));
3933
var_dump(count(get_extension_funcs("standard")));
@@ -44,36 +38,19 @@ var_dump(count(get_extension_funcs("zend")));
4438
echo "Done\n";
4539
?>
4640
--EXPECTF--
47-
Warning: get_resource_type() expects exactly 1 parameter, 0 given in %s on line %d
48-
NULL
49-
50-
Warning: get_resource_type() expects parameter 1 to be resource, string given in %s on line %d
51-
NULL
5241
string(6) "stream"
5342
string(7) "Unknown"
5443
string(5) "array"
5544
int(%d)
5645
string(5) "array"
5746
int(%d)
58-
59-
Warning: get_loaded_extensions() expects at most 1 parameter, 2 given in %s on line %d
60-
NULL
61-
62-
Warning: get_defined_constants() expects at most 1 parameter, 2 given in %s on line %d
63-
NULL
6447
string(5) "array"
6548
string(5) "array"
6649
int(%d)
6750
string(5) "array"
6851
int(%d)
69-
70-
Warning: get_declared_interfaces() expects exactly 0 parameters, 1 given in %s on line %d
71-
NULL
7252
string(5) "array"
7353
int(%d)
74-
75-
Warning: get_extension_funcs() expects exactly 1 parameter, 0 given in %s on line %d
76-
NULL
7754
bool(false)
7855
string(5) "array"
7956
int(%d)

Zend/tests/018.phpt

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

6-
var_dump(constant());
7-
var_dump(constant("", ""));
86
var_dump(constant(""));
97

10-
var_dump(constant(array()));
11-
128
define("TEST_CONST", 1);
139
var_dump(constant("TEST_CONST"));
1410

@@ -18,17 +14,8 @@ var_dump(constant("TEST_CONST2"));
1814
echo "Done\n";
1915
?>
2016
--EXPECTF--
21-
Warning: constant() expects exactly 1 parameter, 0 given in %s on line %d
22-
NULL
23-
24-
Warning: constant() expects exactly 1 parameter, 2 given in %s on line %d
25-
NULL
26-
2717
Warning: constant(): Couldn't find constant in %s on line %d
2818
NULL
29-
30-
Warning: constant() expects parameter 1 to be string, array given in %s on line %d
31-
NULL
3219
int(1)
3320
string(4) "test"
3421
Done

Zend/tests/020.phpt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ func_get_arg() invalid usage
33
--FILE--
44
<?php
55

6-
var_dump(func_get_arg(1,2,3));
76
var_dump(func_get_arg(1));
8-
var_dump(func_get_arg());
97

108
function bar() {
119
var_dump(func_get_arg(1));
@@ -20,15 +18,9 @@ foo(1,2);
2018
echo "Done\n";
2119
?>
2220
--EXPECTF--
23-
Warning: func_get_arg() expects exactly 1 parameter, 3 given in %s on line %d
24-
NULL
25-
2621
Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d
2722
bool(false)
2823

29-
Warning: func_get_arg() expects exactly 1 parameter, 0 given in %s on line %d
30-
NULL
31-
3224
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
3325
bool(false)
3426
Done

Zend/tests/bug31720.phpt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ Bug #31720 (Invalid object callbacks not caught in array_walk())
44
<?php
55
$array = array('at least one element');
66

7-
array_walk($array, array($nonesuchvar,'show'));
7+
try {
8+
array_walk($array, array($nonesuchvar,'show'));
9+
} catch (TypeError $e) {
10+
echo $e->getMessage(), "\n";
11+
}
812
?>
913
===DONE===
1014
--EXPECTF--
1115
Notice: Undefined variable: nonesuchvar in %s on line %d
12-
13-
Warning: array_walk() expects parameter 2 to be a valid callback, first array member is not a valid class name or object in %s on line %d
16+
array_walk() expects parameter 2 to be a valid callback, first array member is not a valid class name or object
1417
===DONE===

Zend/tests/bug45186.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ $x->test();
3131

3232
call_user_func(array('BAR','x'));
3333
call_user_func('BAR::www');
34-
call_user_func('self::y');
34+
try {
35+
call_user_func('self::y');
36+
} catch (TypeError $e) {
37+
echo $e->getMessage(), "\n";
38+
}
3539

3640
?>
37-
--EXPECTF--
41+
--EXPECT--
3842
__call:
3943
string(3) "ABC"
4044
__call:
@@ -50,5 +54,4 @@ string(1) "y"
5054
ok
5155
__callstatic:
5256
string(3) "www"
53-
54-
Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access self:: when no class scope is active in %sbug45186.php on line 31
57+
call_user_func() expects parameter 1 to be a valid callback, cannot access self:: when no class scope is active

Zend/tests/bug45186_2.phpt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ $x = new bar;
2626
$x->test();
2727

2828
call_user_func(array('BAR','x'));
29-
call_user_func('BAR::www');
30-
call_user_func('self::y');
29+
try {
30+
call_user_func('BAR::www');
31+
} catch (TypeError $e) {
32+
echo $e->getMessage(), "\n";
33+
}
34+
try {
35+
call_user_func('self::y');
36+
} catch (TypeError $e) {
37+
echo $e->getMessage(), "\n";
38+
}
3139

3240
?>
33-
--EXPECTF--
41+
--EXPECT--
3442
__call:
3543
string(3) "ABC"
3644
__call:
@@ -44,7 +52,5 @@ string(1) "y"
4452
__call:
4553
string(1) "y"
4654
ok
47-
48-
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'bar' does not have a method 'www' in %s on line %d
49-
50-
Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access self:: when no class scope is active in %sbug45186_2.php on line 27
55+
call_user_func() expects parameter 1 to be a valid callback, class 'bar' does not have a method 'www'
56+
call_user_func() expects parameter 1 to be a valid callback, cannot access self:: when no class scope is active

Zend/tests/bug46106.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ function test($x) {
1515
}
1616

1717
$x = new ReflectionFunction('str_pad');
18-
test($x);
18+
try {
19+
test($x);
20+
} catch (TypeError $e) {
21+
echo $e->getMessage(), "\n";
22+
}
1923
?>
2024
DONE
2125
--EXPECT--
26+
str_pad() expects at least 2 parameters, 1 given
2227
DONE

Zend/tests/bug51827.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ register_shutdown_function('exploDe');
1616
--EXPECTF--
1717
int(1)
1818

19-
Warning: explode() expects at least 2 parameters, 0 given in Unknown on line %d
19+
Fatal error: Uncaught ArgumentCountError: explode() expects at least 2 parameters, 0 given in [no active file]:0
20+
Stack trace:
21+
#0 [internal function]: explode()
22+
#1 {main}
23+
thrown in [no active file] on line 0

Zend/tests/bug70895.phpt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ Bug #70895 null ptr deref and segfault with crafted callable
33
--FILE--
44
<?php
55

6-
array_map("%n", 0);
7-
array_map("%n %i", 0);
8-
array_map("%n %i aoeu %f aoeu %p", 0);
6+
try {
7+
array_map("%n", 0);
8+
} catch (TypeError $e) {
9+
echo $e->getMessage(), "\n";
10+
}
11+
try {
12+
array_map("%n %i", 0);
13+
} catch (TypeError $e) {
14+
echo $e->getMessage(), "\n";
15+
}
16+
try {
17+
array_map("%n %i aoeu %f aoeu %p", 0);
18+
} catch (TypeError $e) {
19+
echo $e->getMessage(), "\n";
20+
}
921
?>
10-
--EXPECTREGEX--
11-
Warning: array_map\(\) expects parameter 1 to be a valid callback, function '%n' not found or invalid function name in .+
12-
13-
Warning: array_map\(\) expects parameter 1 to be a valid callback, function '%n %i' not found or invalid function name in .+
14-
15-
Warning: array_map\(\) expects parameter 1 to be a valid callback, function '%n %i aoeu %f aoeu %p' not found or invalid function name in .+bug70895.php on line \d+
22+
--EXPECT--
23+
array_map() expects parameter 1 to be a valid callback, function '%n' not found or invalid function name
24+
array_map() expects parameter 1 to be a valid callback, function '%n %i' not found or invalid function name
25+
array_map() expects parameter 1 to be a valid callback, function '%n %i aoeu %f aoeu %p' not found or invalid function name

0 commit comments

Comments
 (0)