1--TEST-- 2Test imagecolorstotal() function : error conditions - Pass incorrect number of arguments 3--SKIPIF-- 4<?php 5if(!extension_loaded('gd')) { 6 die('skip gd extension is not loaded'); 7} 8if(!function_exists('imagecolorstotal')) { 9 die('skip imagecolorstotal function is not available'); 10} 11?> 12--FILE-- 13<?php 14/* Prototype : int imagecolorstotal ( resource $image ) 15 * Description: Find out the number of colors in an image's palette 16 * Source code: ext/gd/gd.c 17 */ 18 19echo "*** Testing imagecolorstotal() : error conditions ***\n"; 20 21// Get a resource 22$im = fopen(__FILE__, 'r'); 23 24echo "\n-- Testing imagecolorstotal() function with Zero arguments --\n"; 25var_dump( imagecolorstotal() ); 26 27echo "\n-- Testing imagecolorstotal() function with more than expected no. of arguments --\n"; 28$extra_arg = false; 29var_dump( imagecolorstotal($im, $extra_arg) ); 30 31echo "\n-- Testing imagecolorstotal() function with a invalid resource\n"; 32var_dump( imagecolorstotal($im) ); 33 34fclose($im); 35?> 36===DONE=== 37--EXPECTF-- 38*** Testing imagecolorstotal() : error conditions *** 39 40-- Testing imagecolorstotal() function with Zero arguments -- 41 42Warning: imagecolorstotal() expects exactly 1 parameter, 0 given in %s on line %d 43NULL 44 45-- Testing imagecolorstotal() function with more than expected no. of arguments -- 46 47Warning: imagecolorstotal() expects exactly 1 parameter, 2 given in %s on line %d 48NULL 49 50-- Testing imagecolorstotal() function with a invalid resource 51 52Warning: imagecolorstotal(): supplied resource is not a valid Image resource in %s on line %d 53bool(false) 54===DONE=== 55