Skip to content

Commit 35e092d

Browse files
committed
class_object test fixes
1 parent b9c5690 commit 35e092d

Some content is hidden

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

45 files changed

+48
-672
lines changed

ext/standard/tests/class_object/property_exists_error.phpt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,15 @@ Test property_exists() function : error conditions
1010

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

13-
$object_or_class = "obj";
14-
$property_name = 'string_val';
15-
$extra_arg = 10;
16-
17-
18-
echo "\n-- Testing property_exists() function with more than expected no. of arguments --\n";
19-
var_dump( property_exists($object_or_class, $property_name, $extra_arg) );
20-
21-
22-
echo "\n-- Testing property_exists() function with less than expected no. of arguments --\n";
23-
var_dump( property_exists($object_or_class) );
24-
2513
echo "\n-- Testing property_exists() function with incorrect arguments --\n";
14+
$property_name = 'string_val';
2615
var_dump( property_exists(10, $property_name) );
2716

2817
?>
2918
===DONE===
3019
--EXPECTF--
3120
*** Testing property_exists() : error conditions ***
3221

33-
-- Testing property_exists() function with more than expected no. of arguments --
34-
35-
Warning: property_exists() expects exactly 2 parameters, 3 given in %sproperty_exists_error.php on line %d
36-
NULL
37-
38-
-- Testing property_exists() function with less than expected no. of arguments --
39-
40-
Warning: property_exists() expects exactly 2 parameters, 1 given in %sproperty_exists_error.php on line %d
41-
NULL
42-
4322
-- Testing property_exists() function with incorrect arguments --
4423

4524
Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists_error.php on line %d

ext/standard/tests/general_functions/bug41970.phpt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ Bug #41970 (call_user_func_*() leaks on failure)
66
$a = array(4,3,2);
77

88
var_dump(call_user_func_array("sort", array($a)));
9-
var_dump(call_user_func_array("strlen", array($a)));
9+
try {
10+
var_dump(call_user_func_array("strlen", array($a)));
11+
} catch (TypeError $e) {
12+
echo $e->getMessage(), "\n";
13+
}
1014
var_dump(call_user_func("sort", $a));
11-
var_dump(call_user_func("strlen", $a));
15+
try {
16+
var_dump(call_user_func("strlen", $a));
17+
} catch (TypeError $e) {
18+
echo $e->getMessage(), "\n";
19+
}
1220

1321
echo "Done\n";
1422
?>
1523
--EXPECTF--
1624
Warning: Parameter 1 to sort() expected to be a reference, value given in %sbug41970.php on line 5
1725
bool(true)
18-
19-
Warning: strlen() expects parameter 1 to be string, array given in %sbug41970.php on line 6
20-
NULL
26+
strlen() expects parameter 1 to be string, array given
2127

2228
Warning: Parameter 1 to sort() expected to be a reference, value given in %sbug41970.php on line 7
2329
bool(true)
24-
25-
Warning: strlen() expects parameter 1 to be string, array given in %sbug41970.php on line 8
26-
NULL
30+
strlen() expects parameter 1 to be string, array given
2731
Done

ext/standard/tests/general_functions/callbacks_001.phpt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ class P extends O {
6969
$this->call(array('parent', 'who'));
7070
$this->call(array('P', 'parent::who'));
7171
$this->call(array($this, 'O::who'));
72-
$this->call(array($this, 'B::who'));
72+
try {
73+
$this->call(array($this, 'B::who'));
74+
} catch (TypeError $e) {
75+
echo $e->getMessage(), "\n";
76+
}
7377
}
7478
}
7579

@@ -103,6 +107,5 @@ O
103107
$this|O::who
104108
O
105109
$this|B::who
106-
107-
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'P' is not a subclass of 'B' in %s on line %d
110+
call_user_func() expects parameter 1 to be a valid callback, class 'P' is not a subclass of 'B'
108111
===DONE===

ext/standard/tests/general_functions/callbacks_002.phpt

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,24 @@ call_user_func(): Wrong parameters
33
--FILE--
44
<?php
55

6-
call_user_func(array('Foo', 'bar'));
7-
call_user_func(array(NULL, 'bar'));
8-
call_user_func(array('stdclass', NULL));
6+
try {
7+
call_user_func(array('Foo', 'bar'));
8+
} catch (TypeError $e) {
9+
echo $e->getMessage(), "\n";
10+
}
11+
try {
12+
call_user_func(array(NULL, 'bar'));
13+
} catch (TypeError $e) {
14+
echo $e->getMessage(), "\n";
15+
}
16+
try {
17+
call_user_func(array('stdclass', NULL));
18+
} catch (TypeError $e) {
19+
echo $e->getMessage(), "\n";
20+
}
921

1022
?>
1123
--EXPECTF--
12-
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Foo' not found in %s on line %d
13-
14-
Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d
15-
16-
Warning: call_user_func() expects parameter 1 to be a valid callback, second array member is not a valid method in %s on line %d
24+
call_user_func() expects parameter 1 to be a valid callback, class 'Foo' not found
25+
call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
26+
call_user_func() expects parameter 1 to be a valid callback, second array member is not a valid method

ext/standard/tests/general_functions/error_get_last.phpt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ error_get_last() tests
44
<?php
55

66
var_dump(error_get_last());
7-
var_dump(error_get_last(true));
7+
try {
8+
var_dump(error_get_last(true));
9+
} catch (TypeError $e) {
10+
echo $e->getMessage(), "\n";
11+
}
812
var_dump(error_get_last());
913

1014
$a = $b;
@@ -15,19 +19,7 @@ echo "Done\n";
1519
?>
1620
--EXPECTF--
1721
NULL
18-
19-
Warning: error_get_last() expects exactly 0 parameters, 1 given in %s on line %d
2022
NULL
21-
array(4) {
22-
["type"]=>
23-
int(2)
24-
["message"]=>
25-
string(54) "error_get_last() expects exactly 0 parameters, 1 given"
26-
["file"]=>
27-
string(%i) "%s"
28-
["line"]=>
29-
int(4)
30-
}
3123

3224
Notice: Undefined variable: b in %s on line %d
3325
array(4) {

ext/standard/tests/general_functions/floatval.phpt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ foreach ($not_float_types as $type ) {
9191
var_dump( doubleval($type) );
9292
}
9393

94-
95-
96-
97-
echo "\n*** Testing error conditions ***\n";
98-
//Zero argument
99-
var_dump( floatval() );
100-
var_dump( doubleval() );
101-
102-
//arguments more than expected
103-
var_dump( floatval(TRUE, FALSE) );
104-
var_dump( doubleval(TRUE, FALSE) );
105-
10694
echo "\nDone\n";
10795

10896

@@ -194,18 +182,4 @@ float(1)
194182
float(0)
195183
float(0)
196184

197-
*** Testing error conditions ***
198-
199-
Warning: floatval() expects exactly 1 parameter, 0 given in %s on line %d
200-
NULL
201-
202-
Warning: doubleval() expects exactly 1 parameter, 0 given in %s on line %d
203-
NULL
204-
205-
Warning: floatval() expects exactly 1 parameter, 2 given in %s on line %d
206-
NULL
207-
208-
Warning: doubleval() expects exactly 1 parameter, 2 given in %s on line %d
209-
NULL
210-
211185
Done

ext/standard/tests/general_functions/get_extension_funcs_basic.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ $result = get_extension_funcs("standard");
1414
var_dump(gettype($result));
1515
var_dump(in_array("cos", $result));
1616

17+
// Unknown extension
18+
var_dump(get_extension_funcs("foo"));
19+
1720
?>
1821
===DONE===
1922
--EXPECT--
2023
Simple testcase for get_extension_funcs() function
2124
string(5) "array"
2225
bool(true)
26+
bool(false)
2327
===DONE===

ext/standard/tests/general_functions/get_extension_funcs_error.phpt

Lines changed: 0 additions & 40 deletions
This file was deleted.

ext/standard/tests/general_functions/get_include_path_basic.phpt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,11 @@ if (ini_get("include_path") == get_include_path()) {
1919
echo "FAILED\n";
2020
}
2121

22-
echo "\nError cases:\n";
23-
var_dump(get_include_path(TRUE));
24-
25-
2622
?>
2723
===DONE===
2824
--EXPECTF--
2925
*** Testing get_include_path()
3026
string(1) "."
3127
PASSED
3228

33-
Error cases:
34-
35-
Warning: get_include_path() expects exactly 0 parameters, 1 given in %s on line %d
36-
NULL
3729
===DONE===

ext/standard/tests/general_functions/get_included_files.phpt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ include(dirname(__FILE__)."/get_included_files_inc2.inc");
2222
echo "\n-- List included files atfter including inc2 which will include inc3 which includes inc1 --\n";
2323
var_dump(get_included_files());
2424

25-
echo "\n-- Error cases --\n";
26-
var_dump(get_included_files(true));
27-
2825
?>
2926
===DONE===
3027
--EXPECTF--
@@ -56,8 +53,4 @@ array(4) {
5653
string(%d) "%sget_included_files_inc3.inc"
5754
}
5855

59-
-- Error cases --
60-
61-
Warning: get_included_files() expects exactly 0 parameters, 1 given in %s on line %d
62-
NULL
6356
===DONE===

0 commit comments

Comments
 (0)