Skip to content

Commit 39460fe

Browse files
committed
add tests
1 parent 836241c commit 39460fe

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

ext/gd/tests/gh18005.phpt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
GH-18005: imagesetstyle, imagefilter, imagecrop array values type checks
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
class A {}
8+
$img = imagecreatetruecolor(1, 1);
9+
$styles = array(PHP_INT_MIN, new A());
10+
try {
11+
imagesetstyle($img, $styles);
12+
} catch (\ValueError $e) {
13+
echo $e->getMessage() . PHP_EOL;
14+
}
15+
try {
16+
imagefilter($img, IMG_FILTER_SCATTER, 0, 0, array(new A()));
17+
} catch (\ValueError $e) {
18+
echo $e->getMessage() . PHP_EOL;
19+
}
20+
try {
21+
imagefilter($img, IMG_FILTER_SCATTER, 0, 0, array(-1));
22+
} catch (\ValueError $e) {
23+
echo $e->getMessage() . PHP_EOL;
24+
}
25+
try {
26+
imagecrop($img, array("x" => PHP_INT_MIN, "y" => 0, "width" => 0, "height" => 0));
27+
} catch (\ValueError $e) {
28+
echo $e->getMessage() . PHP_EOL;
29+
}
30+
try {
31+
imagecrop($img, array("x" => 0, "y" => PHP_INT_MIN, "width" => 0, "height" => 0));
32+
} catch (\ValueError $e) {
33+
echo $e->getMessage() . PHP_EOL;
34+
}
35+
try {
36+
imagecrop($img, array("x" => 0, "y" => 0, "width" => PHP_INT_MAX, "height" => 0));
37+
} catch (\ValueError $e) {
38+
echo $e->getMessage() . PHP_EOL;
39+
}
40+
try {
41+
imagecrop($img, array("x" => 0, "y" => 0, "width" => 0, "height" => PHP_INT_MAX));
42+
} catch (\ValueError $e) {
43+
echo $e->getMessage();
44+
}
45+
?>
46+
--EXPECTF--
47+
imagesetstyle(): Argument #2 ($style) value must be of type int, A given
48+
imagefilter(): Argument #5 value must be of type int, A given
49+
imagefilter(): Argument #5 value must be between 0 and 2147483647
50+
imagecrop(): Argument #2 ($rectangle) "x" key must be between %i and %d
51+
imagecrop(): Argument #2 ($rectangle) "y" key must be between %i and %d
52+
imagecrop(): Argument #2 ($rectangle) "width" key must be between %i and %d
53+
imagecrop(): Argument #2 ($rectangle) "height" key must be between %i and %d

0 commit comments

Comments
 (0)