Annotation of embedaddon/php/ext/standard/tests/class_object/class_exists_variation_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test class_exists() function : usage variations - unexpected types for agument 2
3: --FILE--
4: <?php
5: /* Prototype : proto bool class_exists(string classname [, bool autoload])
6: * Description: Checks if the class exists
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 class_exists() : usage variations ***\n";
21:
22: // Initialise function arguments not being substituted (if any)
23: $classname = 'string_val';
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: // string data
67: "string",
68: 'string',
69:
70: // object data
71: new stdclass(),
72:
73: // undefined data
74: $undefined_var,
75:
76: // unset data
77: $unset_var,
78: );
79:
80: // loop through each element of the array for autoload
81:
82: foreach($values as $value) {
83: echo "\nArg value $value \n";
84: var_dump( class_exists($classname, $value) );
85: };
86:
87: echo "Done";
88: ?>
89: --EXPECTF--
90: *** Testing class_exists() : usage variations ***
91: Error: 8 - Undefined variable: undefined_var, %s(71)
92: Error: 8 - Undefined variable: unset_var, %s(74)
93:
94: Arg value 0
95: bool(false)
96:
97: Arg value 1
98: In __autoload(string_val)
99: bool(false)
100:
101: Arg value 12345
102: In __autoload(string_val)
103: bool(false)
104:
105: Arg value -2345
106: In __autoload(string_val)
107: bool(false)
108:
109: Arg value 10.5
110: In __autoload(string_val)
111: bool(false)
112:
113: Arg value -10.5
114: In __autoload(string_val)
115: bool(false)
116:
117: Arg value 101234567000
118: In __autoload(string_val)
119: bool(false)
120:
121: Arg value 1.07654321E-9
122: In __autoload(string_val)
123: bool(false)
124:
125: Arg value 0.5
126: In __autoload(string_val)
127: bool(false)
128:
129: Arg value Array
130: Error: 2 - class_exists() expects parameter 2 to be boolean, array given, %s(81)
131: NULL
132:
133: Arg value Array
134: Error: 2 - class_exists() expects parameter 2 to be boolean, array given, %s(81)
135: NULL
136:
137: Arg value Array
138: Error: 2 - class_exists() expects parameter 2 to be boolean, array given, %s(81)
139: NULL
140:
141: Arg value Array
142: Error: 2 - class_exists() expects parameter 2 to be boolean, array given, %s(81)
143: NULL
144:
145: Arg value Array
146: Error: 2 - class_exists() expects parameter 2 to be boolean, array given, %s(81)
147: NULL
148:
149: Arg value
150: bool(false)
151:
152: Arg value
153: bool(false)
154:
155: Arg value 1
156: In __autoload(string_val)
157: bool(false)
158:
159: Arg value
160: bool(false)
161:
162: Arg value 1
163: In __autoload(string_val)
164: bool(false)
165:
166: Arg value
167: bool(false)
168:
169: Arg value
170: bool(false)
171:
172: Arg value
173: bool(false)
174:
175: Arg value string
176: In __autoload(string_val)
177: bool(false)
178:
179: Arg value string
180: In __autoload(string_val)
181: bool(false)
182: Error: 4096 - Object of class stdClass could not be converted to string, %s(80)
183:
184: Arg value
185: Error: 2 - class_exists() expects parameter 2 to be boolean, object given, %s(81)
186: NULL
187:
188: Arg value
189: bool(false)
190:
191: Arg value
192: bool(false)
193: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>