mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Written by Sanjay Mantoor and reviewed by Pierre.
This commit is contained in:
parent
d0734964ca
commit
562cb168f1
3 changed files with 153 additions and 0 deletions
38
ext/gd/tests/gd_info_error.phpt
Normal file
38
ext/gd/tests/gd_info_error.phpt
Normal 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===
|
35
ext/gd/tests/image_type_to_mime_type_error.phpt
Normal file
35
ext/gd/tests/image_type_to_mime_type_error.phpt
Normal 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: Wrong parameter count for image_type_to_mime_type() in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Testing image_type_to_mime_type() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: Wrong parameter count for image_type_to_mime_type() in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
80
ext/gd/tests/image_type_to_mime_type_variation2.phpt
Normal file
80
ext/gd/tests/image_type_to_mime_type_variation2.phpt
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
--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===
|
Loading…
Add table
Add a link
Reference in a new issue