1--TEST--
2Test imagecolorallocate() function : error conditions
3--SKIPIF--
4<?php
5if(!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$red = 10;
17$green = 10;
18$blue = 10;
19$extra_arg = 10;
20$im = imagecreate(200, 200);
21
22echo "*** Testing imagecolorallocate() : error conditions ***\n";
23
24//Test imagecolorallocate with one more than the expected number of arguments
25echo "\n-- Testing imagecolorallocate() function with more than expected no. of arguments --\n";
26var_dump( imagecolorallocate($im, $red, $green, $blue, $extra_arg) );
27
28// Testing imagecolorallocate with one less than the expected number of arguments
29echo "\n-- Testing imagecolorallocate() function with less than expected no. of arguments --\n";
30var_dump( imagecolorallocate() );
31var_dump( imagecolorallocate($im, $red, $green) );
32?>
33===DONE===
34--EXPECTF--
35*** Testing imagecolorallocate() : error conditions ***
36
37-- Testing imagecolorallocate() function with more than expected no. of arguments --
38
39Warning: imagecolorallocate() expects exactly 4 parameters, 5 given in %s on line %d
40NULL
41
42-- Testing imagecolorallocate() function with less than expected no. of arguments --
43
44Warning: imagecolorallocate() expects exactly 4 parameters, 0 given in %s on line %d
45NULL
46
47Warning: imagecolorallocate() expects exactly 4 parameters, 3 given in %s on line %d
48NULL
49===DONE===