Annotation of embedaddon/php/ext/standard/tests/class_object/class_exists_variation_001.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test class_exists() function : usage variations - unexpected types for agument 1
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: $autoload = true;
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 classname
77:
78: foreach($values as $value) {
79: echo "\nArg value $value \n";
80: var_dump( class_exists($value, $autoload) );
81: };
82:
83: echo "Done";
84: ?>
85: --EXPECTF--
86: *** Testing class_exists() : 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: In __autoload(0)
92: bool(false)
93:
94: Arg value 1
95: In __autoload(1)
96: bool(false)
97:
98: Arg value 12345
99: In __autoload(12345)
100: bool(false)
101:
102: Arg value -2345
103: In __autoload(-2345)
104: bool(false)
105:
106: Arg value 10.5
107: In __autoload(10.5)
108: bool(false)
109:
110: Arg value -10.5
111: In __autoload(-10.5)
112: bool(false)
113:
114: Arg value 101234567000
115: In __autoload(101234567000)
116: bool(false)
117:
118: Arg value 1.07654321E-9
119: In __autoload(1.07654321E-9)
120: bool(false)
121:
122: Arg value 0.5
123: In __autoload(0.5)
124: bool(false)
1.1.1.2 ! misho 125: Error: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
1.1 misho 126:
127: Arg value Array
128: Error: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
129: NULL
1.1.1.2 ! misho 130: Error: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
1.1 misho 131:
132: Arg value Array
133: Error: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
134: NULL
1.1.1.2 ! misho 135: Error: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
1.1 misho 136:
137: Arg value Array
138: Error: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
139: NULL
1.1.1.2 ! misho 140: Error: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
1.1 misho 141:
142: Arg value Array
143: Error: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
144: NULL
1.1.1.2 ! misho 145: Error: 8 - Array to string conversion, %sclass_exists_variation_001.php(%d)
1.1 misho 146:
147: Arg value Array
148: Error: 2 - class_exists() expects parameter 1 to be string, array given, %s(77)
149: NULL
150:
151: Arg value
152: bool(false)
153:
154: Arg value
155: bool(false)
156:
157: Arg value 1
158: In __autoload(1)
159: bool(false)
160:
161: Arg value
162: bool(false)
163:
164: Arg value 1
165: In __autoload(1)
166: bool(false)
167:
168: Arg value
169: bool(false)
170:
171: Arg value
172: bool(false)
173:
174: Arg value
175: bool(false)
176: Error: 4096 - Object of class stdClass could not be converted to string, %s(76)
177:
178: Arg value
179: Error: 2 - class_exists() expects parameter 1 to be string, object given, %s(77)
180: NULL
181:
182: Arg value
183: bool(false)
184:
185: Arg value
186: bool(false)
187: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>