Annotation of embedaddon/php/ext/gd/tests/imagecolorallocate_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test imagecolorallocate() function : usage variations - passing different data types to first argument
3: --SKIPIF--
4: <?php
5: if(!extension_loaded('gd')) {
6: die('skip gd extension is not loaded');
7: }
8: ?>
9: --FILE--
10: <?php
11: /* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
12: * Description: Allocate a color for an image
13: * Source code: ext/gd/gd.c
14: */
15:
16: echo "*** Testing imagecolorallocate() : usage variations ***\n";
17:
18: // Initialise function arguments not being substituted (if any)
19: $red = 10;
20: $green = 10;
21: $blue = 10;
22:
23: $fp = tmpfile();
24:
25: //get an unset variable
26: $unset_var = 10;
27: unset ($unset_var);
28:
29:
30: // define some classes
31: class classWithToString
32: {
33: public function __toString() {
34: return "Class A object";
35: }
36: }
37:
38:
39: class classWithoutToString
40: {
41: }
42:
43: // heredoc string
44: $heredoc = <<<EOT
45: hello world
46: EOT;
47:
48: // add arrays
49: $index_array = array (1, 2, 3);
50: $assoc_array = array ('one' => 1, 'two' => 2);
51:
52: //array of values to iterate over
53: $values = array(
54:
55: // int data
56: 'int 0' => 0,
57: 'int 1' => 1,
58: 'int 12345' => 12345,
59: 'int -12345' => -12345,
60:
61: // float data
62: 'float 10.5' => 10.5,
63: 'float -10.5' => -10.5,
64: 'float 10.1234567e10' => 10.1234567e10,
65: 'float 10.7654321E-10' => 10.7654321E-10,
66: 'float .5' => .5,
67:
68: // array data
69: 'empty array' => array(),
70: 'int indexed array' => $index_array,
71: 'associative array' => $assoc_array,
72: 'nested arrays' => array('foo', $index_array, $assoc_array),
73:
74: // null data
75: 'uppercase NULL' => NULL,
76: 'lowercase null' => null,
77:
78: // boolean data
79: 'lowercase true' => true,
80: 'lowercase false' =>false,
81: 'uppercase TRUE' =>TRUE,
82: 'uppercase FALSE' =>FALSE,
83:
84: // empty data
85: 'empty string DQ' => "",
86: 'empty string SQ' => '',
87:
88: // string data
89: 'string DQ' => "string",
90: 'string SQ' => 'string',
91: 'mixed case string' => "sTrInG",
92: 'heredoc' => $heredoc,
93:
94: // object data
95: 'instance of classWithToString' => new classWithToString(),
96: 'instance of classWithoutToString' => new classWithoutToString(),
97:
98: // undefined data
99: 'undefined var' => @$undefined_var,
100:
101: // unset data
102: 'unset var' => @$unset_var,
103:
104: //resource
105: "file resource" => $fp
106: );
107:
108: // loop through each element of the array for im
109: foreach($values as $key => $value) {
110: echo "\n-- $key --\n";
111: var_dump( imagecolorallocate($value, $red, $green, $blue) );
112: };
113: ?>
114: ===DONE===
115: --EXPECTF--
116: *** Testing imagecolorallocate() : usage variations ***
117:
118: -- int 0 --
119:
120: Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
121: NULL
122:
123: -- int 1 --
124:
125: Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
126: NULL
127:
128: -- int 12345 --
129:
130: Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
131: NULL
132:
133: -- int -12345 --
134:
135: Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d
136: NULL
137:
138: -- float 10.5 --
139:
140: Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
141: NULL
142:
143: -- float -10.5 --
144:
145: Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
146: NULL
147:
148: -- float 10.1234567e10 --
149:
150: Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
151: NULL
152:
153: -- float 10.7654321E-10 --
154:
155: Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
156: NULL
157:
158: -- float .5 --
159:
160: Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d
161: NULL
162:
163: -- empty array --
164:
165: Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
166: NULL
167:
168: -- int indexed array --
169:
170: Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
171: NULL
172:
173: -- associative array --
174:
175: Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
176: NULL
177:
178: -- nested arrays --
179:
180: Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d
181: NULL
182:
183: -- uppercase NULL --
184:
185: Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
186: NULL
187:
188: -- lowercase null --
189:
190: Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
191: NULL
192:
193: -- lowercase true --
194:
195: Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
196: NULL
197:
198: -- lowercase false --
199:
200: Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
201: NULL
202:
203: -- uppercase TRUE --
204:
205: Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
206: NULL
207:
208: -- uppercase FALSE --
209:
210: Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d
211: NULL
212:
213: -- empty string DQ --
214:
215: Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
216: NULL
217:
218: -- empty string SQ --
219:
220: Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
221: NULL
222:
223: -- string DQ --
224:
225: Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
226: NULL
227:
228: -- string SQ --
229:
230: Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
231: NULL
232:
233: -- mixed case string --
234:
235: Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
236: NULL
237:
238: -- heredoc --
239:
240: Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d
241: NULL
242:
243: -- instance of classWithToString --
244:
245: Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d
246: NULL
247:
248: -- instance of classWithoutToString --
249:
250: Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d
251: NULL
252:
253: -- undefined var --
254:
255: Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
256: NULL
257:
258: -- unset var --
259:
260: Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d
261: NULL
262:
263: -- file resource --
264:
265: Warning: imagecolorallocate(): supplied resource is not a valid Image resource in %s on line %d
266: bool(false)
267: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>