Written by Sanjay Mantoor and reviewed by Pierre.

This commit is contained in:
Zoe Slattery 2008-06-10 18:31:37 +00:00
parent bfda5b1b58
commit bc84bcc19c
3 changed files with 192 additions and 0 deletions

View file

@ -0,0 +1,38 @@
--TEST--
Test gd_info() function : error conditions - with more than expected number of arguments
--SKIPIF--
<?php
if(!extension_loaded('gd')) {
die('skip gd extension is not loaded');
}
if(!function_exists('gd_info')) {
die('skip gd_info function is not available');
}
?>
--FILE--
<?php
/* Prototype : array gd_info()
* Description: Retrieve information about the currently installed GD library
* Source code: ext/gd/gd.c
*/
$extra_arg_number = 10;
$extra_arg_string = "Hello";
echo "*** Testing gd_info() : error conditions ***\n";
echo "\n-- Testing gd_info() function with more than expected number of arguments --\n";
var_dump(gd_info($extra_arg_number));
var_dump(gd_info($extra_arg_string, $extra_arg_number));
?>
===DONE===
--EXPECTF--
*** Testing gd_info() : error conditions ***
-- Testing gd_info() function with more than expected number of arguments --
Warning: gd_info() expects exactly 0 parameters, 1 given in %s on line %d
bool(false)
Warning: gd_info() expects exactly 0 parameters, 2 given in %s on line %d
bool(false)
===DONE===

View file

@ -0,0 +1,35 @@
--TEST--
Test image_type_to_mime_type() function : error conditions - Pass incorrect number of arguments
--FILE--
<?php
/* Prototype : proto string image_type_to_mime_type(int imagetype)
* Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
* Source code: ext/standard/image.c
*/
$imagetype = IMAGETYPE_GIF;
$extra_arg = 10;
echo "*** Testing image_type_to_mime_type() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing image_type_to_mime_type() function with Zero arguments --\n";
var_dump( image_type_to_mime_type() );
//Test image_type_to_mime_type with one more than the expected number of arguments
echo "\n-- Testing image_type_to_mime_type() function with more than expected no. of arguments --\n";
var_dump( image_type_to_mime_type($imagetype, $extra_arg) );
?>
===DONE===
--EXPECTF--
*** Testing image_type_to_mime_type() : error conditions ***
-- Testing image_type_to_mime_type() function with Zero arguments --
Warning: image_type_to_mime_type() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-- Testing image_type_to_mime_type() function with more than expected no. of arguments --
Warning: image_type_to_mime_type() expects exactly 1 parameter, 2 given in %s on line %d
NULL
===DONE===

View file

@ -0,0 +1,119 @@
--TEST--
Test image_type_to_mime_type() function : usage variations - Pass decimal, octal, and hexadecimal values as imagetype
--FILE--
<?php
/* Prototype : string image_type_to_mime_type(int imagetype)
* Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
* Source code: ext/standard/image.c
*/
echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
error_reporting(E_ALL ^ E_NOTICE);
$values = array (
//Decimal values
0,
1,
12345,
-12345,
//Octal values
02,
010,
030071,
-030071,
//Hexadecimal values
0x0,
0x1,
0xABCD,
-0xABCD
);
// loop through each element of the array for imagetype
$iterator = 1;
foreach($values as $value) {
echo "\n-- Iteration $iterator --\n";
var_dump( image_type_to_mime_type($value) );
$iterator++;
};
?>
===DONE===
--EXPECT--
*** Testing image_type_to_mime_type() : usage variations ***
-- Iteration 1 --
string(24) "application/octet-stream"
-- Iteration 2 --
string(9) "image/gif"
-- Iteration 3 --
string(24) "application/octet-stream"
-- Iteration 4 --
string(24) "application/octet-stream"
-- Iteration 5 --
string(10) "image/jpeg"
-- Iteration 6 --
string(10) "image/tiff"
-- Iteration 7 --
string(24) "application/octet-stream"
-- Iteration 8 --
string(24) "application/octet-stream"
-- Iteration 9 --
string(24) "application/octet-stream"
-- Iteration 10 --
string(9) "image/gif"
-- Iteration 11 --
string(24) "application/octet-stream"
-- Iteration 12 --
string(24) "application/octet-stream"
===DONE===
--UEXPECT--
*** Testing image_type_to_mime_type() : usage variations ***
-- Iteration 1 --
unicode(24) "application/octet-stream"
-- Iteration 2 --
unicode(9) "image/gif"
-- Iteration 3 --
unicode(24) "application/octet-stream"
-- Iteration 4 --
unicode(24) "application/octet-stream"
-- Iteration 5 --
unicode(10) "image/jpeg"
-- Iteration 6 --
unicode(10) "image/tiff"
-- Iteration 7 --
unicode(24) "application/octet-stream"
-- Iteration 8 --
unicode(24) "application/octet-stream"
-- Iteration 9 --
unicode(24) "application/octet-stream"
-- Iteration 10 --
unicode(9) "image/gif"
-- Iteration 11 --
unicode(24) "application/octet-stream"
-- Iteration 12 --
unicode(24) "application/octet-stream"
===DONE===