Annotation of embedaddon/php/ext/standard/tests/class_object/is_subclass_of_variation_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test is_subclass_of() function : usage variations - unexpected type for arg 2
3: --FILE--
4: <?php
5: /* Prototype : proto bool is_subclass_of(object object, string class_name)
6: * Description: Returns true if the object has this class as one of its parents
7: * Source code: Zend/zend_builtin_functions.c
8: * Alias to functions:
9: */
10:
11: function __autoload($className) {
12: echo "In __autoload($className)\n";
13: }
14:
15: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
16: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
17: }
18: set_error_handler('test_error_handler');
19:
20: echo "*** Testing is_subclass_of() : usage variations ***\n";
21:
22: // Initialise function arguments not being substituted (if any)
23: $object = new stdclass();
24:
25: //get an unset variable
26: $unset_var = 10;
27: unset ($unset_var);
28:
29: //array of values to iterate over
30: $values = array(
31:
32: // int data
33: 0,
34: 1,
35: 12345,
36: -2345,
37:
38: // float data
39: 10.5,
40: -10.5,
41: 10.1234567e10,
42: 10.7654321E-10,
43: .5,
44:
45: // array data
46: array(),
47: array(0),
48: array(1),
49: array(1, 2),
50: array('color' => 'red', 'item' => 'pen'),
51:
52: // null data
53: NULL,
54: null,
55:
56: // boolean data
57: true,
58: false,
59: TRUE,
60: FALSE,
61:
62: // empty data
63: "",
64: '',
65:
66: // object data
67: new stdclass(),
68:
69: // undefined data
70: $undefined_var,
71:
72: // unset data
73: $unset_var,
74: );
75:
76: // loop through each element of the array for class_name
77:
78: foreach($values as $value) {
79: echo "\nArg value $value \n";
80: var_dump( is_subclass_of($object, $value) );
81: };
82:
83: echo "Done";
84: ?>
85: --EXPECTF--
86: *** Testing is_subclass_of() : usage variations ***
87: Error: 8 - Undefined variable: undefined_var, %s(67)
88: Error: 8 - Undefined variable: unset_var, %s(70)
89:
90: Arg value 0
91: bool(false)
92:
93: Arg value 1
94: bool(false)
95:
96: Arg value 12345
97: bool(false)
98:
99: Arg value -2345
100: bool(false)
101:
102: Arg value 10.5
103: bool(false)
104:
105: Arg value -10.5
106: bool(false)
107:
108: Arg value 101234567000
109: bool(false)
110:
111: Arg value 1.07654321E-9
112: bool(false)
113:
114: Arg value 0.5
115: bool(false)
116:
117: Arg value Array
118: Error: 2 - is_subclass_of() expects parameter 2 to be string, array given, %s(%d)
119: NULL
120:
121: Arg value Array
122: Error: 2 - is_subclass_of() expects parameter 2 to be string, array given, %s(%d)
123: NULL
124:
125: Arg value Array
126: Error: 2 - is_subclass_of() expects parameter 2 to be string, array given, %s(%d)
127: NULL
128:
129: Arg value Array
130: Error: 2 - is_subclass_of() expects parameter 2 to be string, array given, %s(%d)
131: NULL
132:
133: Arg value Array
134: Error: 2 - is_subclass_of() expects parameter 2 to be string, array given, %s(%d)
135: NULL
136:
137: Arg value
138: bool(false)
139:
140: Arg value
141: bool(false)
142:
143: Arg value 1
144: bool(false)
145:
146: Arg value
147: bool(false)
148:
149: Arg value 1
150: bool(false)
151:
152: Arg value
153: bool(false)
154:
155: Arg value
156: bool(false)
157:
158: Arg value
159: bool(false)
160: Error: 4096 - Object of class stdClass could not be converted to string, %s(%d)
161:
162: Arg value
163: Error: 2 - is_subclass_of() expects parameter 2 to be string, object given, %s(%d)
164: NULL
165:
166: Arg value
167: bool(false)
168:
169: Arg value
170: bool(false)
171: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>