Annotation of embedaddon/php/ext/standard/tests/class_object/trait_exists_variation_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test trait_exists() function : usage variations - unexpected types for agument 2
3: --FILE--
4: <?php
5: /* Prototype : proto bool trait_exists(string traitname [, bool autoload])
6: * Description: Checks if the trait exists
7: * Source code: Zend/zend_builtin_functions.c
8: * Alias to functions:
9: */
10:
11: function __autoload($traitName) {
12: echo "In __autoload($traitName)\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 trait_exists() : usage variations ***\n";
21:
22: // Initialise function arguments not being substituted (if any)
23: $traitname = '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( trait_exists($traitname, $value) );
85: };
86:
87: echo "Done";
88: ?>
89: --EXPECTF--
90: *** Testing trait_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: Error: 8 - Array to string conversion, %strait_exists_variation_002.php(%d)
129:
130: Arg value Array
131: Error: 2 - trait_exists() expects parameter 2 to be boolean, array given, %s(81)
132: NULL
133: Error: 8 - Array to string conversion, %strait_exists_variation_002.php(%d)
134:
135: Arg value Array
136: Error: 2 - trait_exists() expects parameter 2 to be boolean, array given, %s(81)
137: NULL
138: Error: 8 - Array to string conversion, %strait_exists_variation_002.php(%d)
139:
140: Arg value Array
141: Error: 2 - trait_exists() expects parameter 2 to be boolean, array given, %s(81)
142: NULL
143: Error: 8 - Array to string conversion, %strait_exists_variation_002.php(%d)
144:
145: Arg value Array
146: Error: 2 - trait_exists() expects parameter 2 to be boolean, array given, %s(81)
147: NULL
148: Error: 8 - Array to string conversion, %strait_exists_variation_002.php(%d)
149:
150: Arg value Array
151: Error: 2 - trait_exists() expects parameter 2 to be boolean, array given, %s(81)
152: NULL
153:
154: Arg value
155: bool(false)
156:
157: Arg value
158: bool(false)
159:
160: Arg value 1
161: In __autoload(string_val)
162: bool(false)
163:
164: Arg value
165: bool(false)
166:
167: Arg value 1
168: In __autoload(string_val)
169: bool(false)
170:
171: Arg value
172: bool(false)
173:
174: Arg value
175: bool(false)
176:
177: Arg value
178: bool(false)
179:
180: Arg value string
181: In __autoload(string_val)
182: bool(false)
183:
184: Arg value string
185: In __autoload(string_val)
186: bool(false)
187: Error: 4096 - Object of class stdClass could not be converted to string, %s(80)
188:
189: Arg value
190: Error: 2 - trait_exists() expects parameter 2 to be boolean, object given, %s(81)
191: NULL
192:
193: Arg value
194: bool(false)
195:
196: Arg value
197: bool(false)
198: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>