mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
New image tests. Tested on WIndows, Linux and Linux 64 bit
This commit is contained in:
parent
62c51d8d2d
commit
d8ab16b683
13 changed files with 711 additions and 0 deletions
BIN
ext/standard/tests/image/2x2mm.tif
Normal file
BIN
ext/standard/tests/image/2x2mm.tif
Normal file
Binary file not shown.
BIN
ext/standard/tests/image/75x50.wbmp
Normal file
BIN
ext/standard/tests/image/75x50.wbmp
Normal file
Binary file not shown.
59
ext/standard/tests/image/75x50.xbm
Normal file
59
ext/standard/tests/image/75x50.xbm
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#define Xbitmap_width 75
|
||||||
|
#define Xbitmap_height 50
|
||||||
|
static unsigned char Xbitmap_bits[] = {
|
||||||
|
0xfd, 0xdb, 0xf5, 0xbf, 0xef, 0x7b, 0xbb, 0xae, 0xaa,
|
||||||
|
0x07, 0xff, 0x77, 0xbf, 0xea, 0xba, 0xee, 0xef, 0xfb,
|
||||||
|
0xff, 0x06, 0xff, 0xdf, 0xed, 0xbf, 0xdf, 0xbb, 0xba,
|
||||||
|
0x5e, 0x55, 0x05, 0xff, 0x77, 0xbf, 0xf5, 0xe2, 0xee,
|
||||||
|
0xef, 0xeb, 0x55, 0x03, 0xff, 0xdf, 0x75, 0x1f, 0xc0,
|
||||||
|
0x7b, 0xfb, 0xfe, 0xaa, 0x06, 0xff, 0x77, 0xdf, 0x07,
|
||||||
|
0xe8, 0xdf, 0xae, 0xaf, 0xa5, 0x06, 0x5f, 0xdf, 0xeb,
|
||||||
|
0x81, 0xe2, 0xff, 0xf7, 0xfa, 0x92, 0x06, 0xff, 0xf7,
|
||||||
|
0x7e, 0x20, 0xf5, 0xff, 0xbe, 0x6f, 0xab, 0x06, 0xff,
|
||||||
|
0x7f, 0x5b, 0x90, 0xe0, 0xff, 0xdb, 0xf6, 0x55, 0x05,
|
||||||
|
0xff, 0xc7, 0x3f, 0x54, 0xf4, 0xff, 0xff, 0x1f, 0x29,
|
||||||
|
0x07, 0xdf, 0x3d, 0x09, 0x02, 0xea, 0xff, 0x57, 0xf2,
|
||||||
|
0xd6, 0x05, 0x7d, 0xff, 0x84, 0xea, 0xff, 0xff, 0x0f,
|
||||||
|
0xf9, 0x7d, 0x07, 0xd7, 0x8d, 0x47, 0xf5, 0xc3, 0xfe,
|
||||||
|
0xff, 0xdf, 0xdd, 0x05, 0x7b, 0xcd, 0xc7, 0xfa, 0xe8,
|
||||||
|
0xfe, 0x7f, 0x9f, 0x75, 0x07, 0xdd, 0xab, 0xa0, 0x1a,
|
||||||
|
0x00, 0xe1, 0x3b, 0xf0, 0xdf, 0x06, 0x6f, 0x3d, 0x11,
|
||||||
|
0x0c, 0xab, 0xf6, 0xff, 0xf7, 0xf4, 0x03, 0xfd, 0xb3,
|
||||||
|
0xa1, 0x86, 0x4b, 0xfe, 0xff, 0x6d, 0xbf, 0x06, 0xb7,
|
||||||
|
0xba, 0x10, 0xc3, 0x22, 0x6d, 0xff, 0xe7, 0xea, 0x07,
|
||||||
|
0xed, 0xbb, 0x88, 0xf2, 0x57, 0xf7, 0xff, 0x6b, 0xbe,
|
||||||
|
0x02, 0x7f, 0xb3, 0xa4, 0x81, 0x00, 0xfc, 0xff, 0x6f,
|
||||||
|
0xef, 0x07, 0xd5, 0xbb, 0x90, 0x08, 0x72, 0xff, 0xff,
|
||||||
|
0x6b, 0xfa, 0x06, 0x7f, 0x33, 0x48, 0x09, 0xa8, 0xf7,
|
||||||
|
0xff, 0x6f, 0xaf, 0x03, 0x2d, 0xb5, 0xa4, 0x08, 0x00,
|
||||||
|
0xfc, 0xff, 0xef, 0xe6, 0x06, 0x97, 0x3a, 0xc8, 0xac,
|
||||||
|
0xad, 0x76, 0xff, 0x67, 0x90, 0x07, 0x4d, 0x34, 0xa4,
|
||||||
|
0x58, 0x77, 0xa9, 0xff, 0xef, 0xaa, 0x06, 0x97, 0xb2,
|
||||||
|
0xff, 0x5f, 0xdb, 0xd2, 0x59, 0x71, 0x84, 0x03, 0xad,
|
||||||
|
0xb4, 0xfe, 0x57, 0xa5, 0xec, 0x28, 0x61, 0x55, 0x07,
|
||||||
|
0x17, 0xba, 0xff, 0xff, 0xff, 0xb6, 0x94, 0x70, 0xa2,
|
||||||
|
0x05, 0xdd, 0xb3, 0xfd, 0x07, 0x52, 0xff, 0x28, 0x61,
|
||||||
|
0xab, 0x07, 0xb7, 0xba, 0xff, 0xbf, 0x88, 0xea, 0x94,
|
||||||
|
0xe8, 0xfe, 0x02, 0xfd, 0x3b, 0xff, 0xff, 0x57, 0x00,
|
||||||
|
0x9a, 0x70, 0xba, 0x07, 0xb7, 0xb3, 0xff, 0xdf, 0x26,
|
||||||
|
0x6f, 0x44, 0x6c, 0xef, 0x06, 0xed, 0xba, 0xfe, 0xbf,
|
||||||
|
0x93, 0x1a, 0x2b, 0x68, 0xb5, 0x03, 0xdf, 0xb5, 0xfb,
|
||||||
|
0xff, 0x49, 0x1f, 0x45, 0xe4, 0xfe, 0x06, 0xb5, 0x97,
|
||||||
|
0xff, 0xff, 0x97, 0x86, 0x22, 0x0e, 0xaf, 0x07, 0x7f,
|
||||||
|
0x23, 0x60, 0x1f, 0x20, 0xc0, 0x12, 0xa8, 0xf6, 0x05,
|
||||||
|
0xd5, 0x85, 0xf7, 0xff, 0x5b, 0xf0, 0x2a, 0x0b, 0x5d,
|
||||||
|
0x07, 0x7f, 0x81, 0xff, 0xff, 0x3b, 0x7e, 0x1d, 0x8f,
|
||||||
|
0xfc, 0x05, 0xd5, 0xa3, 0xd6, 0xff, 0xff, 0xbf, 0x8a,
|
||||||
|
0x4e, 0x55, 0x07, 0xff, 0x8a, 0x00, 0xff, 0xbf, 0x44,
|
||||||
|
0x02, 0xa8, 0xfe, 0x05, 0xb5, 0xd5, 0xff, 0xff, 0xbf,
|
||||||
|
0x12, 0xc1, 0x9f, 0xaa, 0x02, 0xee, 0xbb, 0x6b, 0xff,
|
||||||
|
0x5f, 0xa4, 0xf0, 0x76, 0x55, 0x05, 0xb5, 0xee, 0xfd,
|
||||||
|
0xf7, 0x3f, 0x29, 0xa8, 0xdd, 0xad, 0x00, 0xfe, 0x7b,
|
||||||
|
0xaf, 0xfe, 0xbf, 0x04, 0xfc, 0xfb, 0x75, 0x01, 0xf5,
|
||||||
|
0xad, 0xfd, 0xdb, 0x3f, 0x01, 0xb7, 0x56, 0xbd, 0x02,
|
||||||
|
0x7c, 0xff, 0xb7, 0xfe, 0x37, 0x60, 0xed, 0xff, 0x6d,
|
||||||
|
0x01, 0xee, 0x55, 0xed, 0x57, 0x1f, 0xaa, 0x7f, 0x55,
|
||||||
|
0x55, 0x01, 0xbb, 0xff, 0x7f, 0xfd, 0xb5, 0xfa, 0xd5,
|
||||||
|
0xff, 0x55, 0x05, 0x55, 0x54, 0xd5, 0x6f, 0xdf, 0x6f,
|
||||||
|
0xff, 0xaa, 0x2a, 0x02, 0x57, 0xff, 0x7f, 0xb5, 0x75,
|
||||||
|
0xb5, 0x55, 0xff, 0x81, 0x07};
|
38
ext/standard/tests/image/getimagesize_error1.phpt
Normal file
38
ext/standard/tests/image/getimagesize_error1.phpt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
--TEST--
|
||||||
|
Test getimagesize() function : error conditions - wrong number of args
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : error conditions ***\n";
|
||||||
|
|
||||||
|
// Zero arguments
|
||||||
|
echo "\n-- Testing getimagesize() function with Zero arguments --\n";
|
||||||
|
var_dump( getimagesize() );
|
||||||
|
|
||||||
|
//Test getimagesize with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing getimagesize() function with more than expected no. of arguments --\n";
|
||||||
|
$imagefile = 'string_val';
|
||||||
|
$info = array(1, 2);
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( getimagesize($imagefile, $info, $extra_arg) );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing getimagesize() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing getimagesize() function with Zero arguments --
|
||||||
|
|
||||||
|
Warning: getimagesize() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing getimagesize() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: getimagesize() expects at most 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
37
ext/standard/tests/image/getimagesize_jpgapp.phpt
Normal file
37
ext/standard/tests/image/getimagesize_jpgapp.phpt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
--TEST--
|
||||||
|
Test getimagesize() function : basic functionality - load APP info from jpeg.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!defined("IMAGETYPE_JPEG")) {
|
||||||
|
die("skip jpeg format is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load APP info from jpeg
|
||||||
|
*/
|
||||||
|
|
||||||
|
$arr['this'] = "will";
|
||||||
|
$arr['all'] = "be destroyed!";
|
||||||
|
$arr['APP1'] = "and this too";
|
||||||
|
|
||||||
|
getimagesize( dirname(__FILE__)."/testAPP.jpg", $arr);
|
||||||
|
|
||||||
|
foreach ($arr as $key => $value) {
|
||||||
|
echo "$key - length: ". strlen($value) ."; md5: " . md5($value) . "\n" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
APP1 - length: 1717; md5: 02cbf4ba6640c131422483138c968516
|
||||||
|
APP2 - length: 7275; md5: f5036ccca2031e8bf932bcbd4aca4355
|
||||||
|
APP13 - length: 42; md5: 2202998bd05e78bcb419f08c070d6f61
|
||||||
|
===DONE===
|
39
ext/standard/tests/image/getimagesize_tif_mm.phpt
Normal file
39
ext/standard/tests/image/getimagesize_tif_mm.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
GetImageSize() for tiff format with big-endian (aka Motorola, aka MM) ordering
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!defined("IMAGETYPE_TIFF_MM")) {
|
||||||
|
die("skip tiff_mm file format is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : tiff_mm format ***\n";
|
||||||
|
var_dump(getimagesize(dirname(__FILE__) . "/2x2mm.tif", $arr));
|
||||||
|
var_dump($arr);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing getimagesize() : tiff_mm format ***
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
int(2)
|
||||||
|
[1]=>
|
||||||
|
int(2)
|
||||||
|
[2]=>
|
||||||
|
int(8)
|
||||||
|
[3]=>
|
||||||
|
string(20) "width="2" height="2""
|
||||||
|
["mime"]=>
|
||||||
|
string(10) "image/tiff"
|
||||||
|
}
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
===DONE===
|
185
ext/standard/tests/image/getimagesize_variation1.phpt
Normal file
185
ext/standard/tests/image/getimagesize_variation1.phpt
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
--TEST--
|
||||||
|
Test getimagesize() function : usage variations - unexpected type for arg 1
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : usage variations ***\n";
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted (if any)
|
||||||
|
$info = array(1, 2);
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
//array of values to iterate over
|
||||||
|
$values = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
"0" => 0,
|
||||||
|
"1" => 1,
|
||||||
|
"12345" => 12345,
|
||||||
|
"-2345" => -2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
"10.5" => 10.5,
|
||||||
|
"-10.5" => -10.5,
|
||||||
|
"10.1234567e5" => 10.1234567e10,
|
||||||
|
"10.7654321e-5" => 10.7654321E-5,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// array data
|
||||||
|
"array()" => array(),
|
||||||
|
"array(0)" => array(0),
|
||||||
|
"array(1)" => array(1),
|
||||||
|
"array(1, 2)" => array(1, 2),
|
||||||
|
"array('color' => 'red', 'item' => 'pen')" => array('color' => 'red', 'item' => 'pen'),
|
||||||
|
|
||||||
|
// null data
|
||||||
|
"NULL" => NULL,
|
||||||
|
"null" => null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
"true" => true,
|
||||||
|
"false" => false,
|
||||||
|
"TRUE" => TRUE,
|
||||||
|
"FALSE" => FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
"\"\"" => "",
|
||||||
|
"''" => '',
|
||||||
|
|
||||||
|
// object data
|
||||||
|
"new stdclass()" => new stdclass(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
"undefined_var" => $undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
"unset_var" => $unset_var,
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for imagefile
|
||||||
|
|
||||||
|
foreach($values as $key => $value) {
|
||||||
|
echo "\n-- Arg value: $key --\n";
|
||||||
|
var_dump( getimagesize($value, $info) );
|
||||||
|
};
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing getimagesize() : usage variations ***
|
||||||
|
Error: 8 - Undefined variable: undefined_var, %s(%d)
|
||||||
|
Error: 8 - Undefined variable: unset_var, %s(%d)
|
||||||
|
|
||||||
|
-- Arg value: 0 --
|
||||||
|
Error: 2 - getimagesize(0): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: 1 --
|
||||||
|
Error: 2 - getimagesize(1): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: 12345 --
|
||||||
|
Error: 2 - getimagesize(12345): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: -2345 --
|
||||||
|
Error: 2 - getimagesize(-2345): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: 10.5 --
|
||||||
|
Error: 2 - getimagesize(10.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: -10.5 --
|
||||||
|
Error: 2 - getimagesize(-10.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: 10.1234567e5 --
|
||||||
|
Error: 2 - getimagesize(101234567000): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: 10.7654321e-5 --
|
||||||
|
Error: 2 - getimagesize(0.000107654321): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: 12346 --
|
||||||
|
Error: 2 - getimagesize(0.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: array() --
|
||||||
|
Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Arg value: array(0) --
|
||||||
|
Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Arg value: array(1) --
|
||||||
|
Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Arg value: array(1, 2) --
|
||||||
|
Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Arg value: array('color' => 'red', 'item' => 'pen') --
|
||||||
|
Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Arg value: NULL --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: null --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: true --
|
||||||
|
Error: 2 - getimagesize(1): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: false --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: TRUE --
|
||||||
|
Error: 2 - getimagesize(1): failed to open stream: No such file or directory, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: FALSE --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: "" --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: '' --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: new stdclass() --
|
||||||
|
Error: 2 - getimagesize() expects parameter 1 to be string, object given, %s(%d)
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Arg value: undefined_var --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Arg value: unset_var --
|
||||||
|
Error: 2 - getimagesize(): Filename cannot be empty, %s(%d)
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
167
ext/standard/tests/image/getimagesize_variation2.phpt
Normal file
167
ext/standard/tests/image/getimagesize_variation2.phpt
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
--TEST--
|
||||||
|
Test getimagesize() function : usage variations - unexpected type for arg 2
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!defined("IMAGETYPE_JPEG")) {
|
||||||
|
die("skip jpeg format is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||||
|
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||||
|
}
|
||||||
|
set_error_handler('test_error_handler');
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : usage variations ***\n";
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted (if any)
|
||||||
|
$imagefile = dirname(__FILE__)."/test1pix.jpg";
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
//array of values to iterate over
|
||||||
|
$values = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
"0" => 0,
|
||||||
|
"1" => 1,
|
||||||
|
"12345" => 12345,
|
||||||
|
"-2345" => -2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
"10.5" => 10.5,
|
||||||
|
"-10.5" => -10.5,
|
||||||
|
"10.1234567e5" => 10.1234567e10,
|
||||||
|
"10.7654321e-5" => 10.7654321E-5,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// array data
|
||||||
|
"array()" => array(),
|
||||||
|
"array(0)" => array(0),
|
||||||
|
"array(1)" => array(1),
|
||||||
|
"array(1, 2)" => array(1, 2),
|
||||||
|
"array('color' => 'red', 'item' => 'pen')" => array('color' => 'red', 'item' => 'pen'),
|
||||||
|
|
||||||
|
// null data
|
||||||
|
"NULL" => NULL,
|
||||||
|
"null" => null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
"true" => true,
|
||||||
|
"false" => false,
|
||||||
|
"TRUE" => TRUE,
|
||||||
|
"FALSE" => FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
"\"\"" => "",
|
||||||
|
"''" => '',
|
||||||
|
|
||||||
|
// object data
|
||||||
|
"new stdclass()" => new stdclass(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
"undefined_var" => $undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
"unset_var" => $unset_var,
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of the array for info
|
||||||
|
|
||||||
|
foreach($values as $key => $value) {
|
||||||
|
echo "\n-- Arg value $key --\n";
|
||||||
|
getimagesize($imagefile, $value);
|
||||||
|
var_dump(bin2hex($value["APP0"]));
|
||||||
|
};
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing getimagesize() : usage variations ***
|
||||||
|
Error: 8 - Undefined variable: undefined_var, %s(%d)
|
||||||
|
Error: 8 - Undefined variable: unset_var, %s(%d)
|
||||||
|
|
||||||
|
-- Arg value 0 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value 1 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value 12345 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value -2345 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value 10.5 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value -10.5 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value 10.1234567e5 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value 10.7654321e-5 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value 12346 --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value array() --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value array(0) --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value array(1) --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value array(1, 2) --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value array('color' => 'red', 'item' => 'pen') --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value NULL --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value null --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value true --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value false --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value TRUE --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value FALSE --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value "" --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value '' --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value new stdclass() --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value undefined_var --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
|
||||||
|
-- Arg value unset_var --
|
||||||
|
string(28) "4a46494600010201006000600000"
|
||||||
|
===DONE===
|
70
ext/standard/tests/image/getimagesize_variation3.phpt
Normal file
70
ext/standard/tests/image/getimagesize_variation3.phpt
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
--TEST--
|
||||||
|
Test getimagesize() function : variation - Passing non image files
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$file_types_array = array (
|
||||||
|
//File containing text string
|
||||||
|
"File with text data" => "test.txt",
|
||||||
|
|
||||||
|
//File containing forcibly corrupted bmp image
|
||||||
|
"File with corrupted BMP data" => "200x100_unknown.unknown",
|
||||||
|
|
||||||
|
//File which doesn't exist
|
||||||
|
"Non-existent file" => "nofile.ext",
|
||||||
|
|
||||||
|
//File having no data
|
||||||
|
"Empty File" => "blank_file.bmp"
|
||||||
|
);
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : variation ***\n";
|
||||||
|
|
||||||
|
//loop through each element of the array for filename
|
||||||
|
foreach($file_types_array as $key => $filename) {
|
||||||
|
echo "\n-- $key ($filename) --\n";
|
||||||
|
var_dump( getimagesize(dirname(__FILE__)."/$filename" ) );
|
||||||
|
var_dump( getimagesize(dirname(__FILE__)."/$filename", $info) );
|
||||||
|
var_dump( $info );
|
||||||
|
};
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing getimagesize() : variation ***
|
||||||
|
|
||||||
|
-- File with text data (test.txt) --
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
-- File with corrupted BMP data (200x100_unknown.unknown) --
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Non-existent file (nofile.ext) --
|
||||||
|
|
||||||
|
Warning: getimagesize(%snofile.ext): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: getimagesize(%snofile.ext): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Empty File (blank_file.bmp) --
|
||||||
|
|
||||||
|
Notice: getimagesize(): Read error! in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Notice: getimagesize(): Read error! in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
===DONE===
|
38
ext/standard/tests/image/getimagesize_variation4.phpt
Normal file
38
ext/standard/tests/image/getimagesize_variation4.phpt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
--TEST--
|
||||||
|
Test getimagesize() function : variation - For shockwave-flash format
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!defined("IMAGETYPE_SWC") || !extension_loaded('zlib')) {
|
||||||
|
die("skip zlib extension is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : variation ***\n";
|
||||||
|
|
||||||
|
var_dump( getimagesize(dirname(__FILE__)."/test13pix.swf", $info) );
|
||||||
|
var_dump( $info );
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing getimagesize() : variation ***
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
int(550)
|
||||||
|
[1]=>
|
||||||
|
int(400)
|
||||||
|
[2]=>
|
||||||
|
int(13)
|
||||||
|
[3]=>
|
||||||
|
string(24) "width="550" height="400""
|
||||||
|
["mime"]=>
|
||||||
|
string(29) "application/x-shockwave-flash"
|
||||||
|
}
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
===DONE===
|
39
ext/standard/tests/image/getimagesize_wbmp.phpt
Normal file
39
ext/standard/tests/image/getimagesize_wbmp.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
GetImageSize() for wbmp format
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!defined("IMAGETYPE_WBMP")) {
|
||||||
|
die("skip wbmp file format is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : wbmp format ***\n";
|
||||||
|
var_dump(getimagesize(dirname(__FILE__) . "/75x50.wbmp", $arr));
|
||||||
|
var_dump($arr);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing getimagesize() : wbmp format ***
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
int(75)
|
||||||
|
[1]=>
|
||||||
|
int(50)
|
||||||
|
[2]=>
|
||||||
|
int(15)
|
||||||
|
[3]=>
|
||||||
|
string(22) "width="75" height="50""
|
||||||
|
["mime"]=>
|
||||||
|
string(18) "image/vnd.wap.wbmp"
|
||||||
|
}
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
===DONE===
|
39
ext/standard/tests/image/getimagesize_xbm.phpt
Normal file
39
ext/standard/tests/image/getimagesize_xbm.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
GetImageSize() for xbm format
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!defined("IMAGETYPE_XBM")) {
|
||||||
|
die("skip xbm file format is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : proto array getimagesize(string imagefile [, array info])
|
||||||
|
* Description: Get the size of an image as 4-element array
|
||||||
|
* Source code: ext/standard/image.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing getimagesize() : xbm format ***\n";
|
||||||
|
var_dump(getimagesize(dirname(__FILE__) . "/75x50.xbm", $arr));
|
||||||
|
var_dump($arr);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing getimagesize() : xbm format ***
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
int(75)
|
||||||
|
[1]=>
|
||||||
|
int(50)
|
||||||
|
[2]=>
|
||||||
|
int(16)
|
||||||
|
[3]=>
|
||||||
|
string(22) "width="75" height="50""
|
||||||
|
["mime"]=>
|
||||||
|
string(9) "image/xbm"
|
||||||
|
}
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
===DONE===
|
BIN
ext/standard/tests/image/testAPP.jpg
Normal file
BIN
ext/standard/tests/image/testAPP.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Loading…
Add table
Add a link
Reference in a new issue