Skip to content

Commit 4ba2334

Browse files
authored
ext/gd: applied fixers to improve test robustness (#23132)
1 parent 8551dc6 commit 4ba2334

39 files changed

Lines changed: 149 additions & 149 deletions

‎ext/gd/tests/avif_decode_encode.phpt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ gd
3939
try {
4040
imageavif($img, $outfile, 1234);
4141
} catch (\ValueError $e) {
42-
echo $e->getMessage() . PHP_EOL;
42+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
4343
}
4444

4545
echo 'Encoding AVIF with illegal speed: ';
4646

4747
try {
4848
imageavif($img, $outfile, 70, 1234);
4949
} catch (\ValueError $e) {
50-
echo $e->getMessage() . PHP_EOL;
50+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
5151
}
5252

5353
echo 'Encoding AVIF losslessly... ';
@@ -75,8 +75,8 @@ Default AVIF encoding: ok
7575
Encoding AVIF at quality 70: ok
7676
Encoding AVIF at quality 70 with speed 5: ok
7777
Encoding AVIF with default quality: ok
78-
Encoding AVIF with illegal quality: imageavif(): Argument #3 ($quality) must be between -1 and 100
79-
Encoding AVIF with illegal speed: imageavif(): Argument #4 ($speed) must be between -1 and 10
78+
Encoding AVIF with illegal quality: ValueError: imageavif(): Argument #3 ($quality) must be between -1 and 100
79+
Encoding AVIF with illegal speed: ValueError: imageavif(): Argument #4 ($speed) must be between -1 and 10
8080
Encoding AVIF losslessly... ok
8181
Decoding the AVIF we just wrote...
8282
What is the mean squared error of the two images? 0

‎ext/gd/tests/bug66356.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $arr = array("x" => 2147483647, "y" => 2147483647, "width" => 10, "height" => 10
1313
try {
1414
imagecrop($img, $arr);
1515
} catch (\ValueError $e) {
16-
echo $e->getMessage() . PHP_EOL;
16+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1717
}
1818
print_r($arr);
1919

@@ -32,7 +32,7 @@ var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => 65535, "height" =>
3232
--EXPECTF--
3333
object(GdImage)#2 (0) {
3434
}
35-
imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys
35+
ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys
3636
Array
3737
(
3838
[x] => 2147483647

‎ext/gd/tests/bug72337.phpt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ $im = imagecreatetruecolor(1, 1);
88
try {
99
imagescale($im, 1, 1, -10);
1010
} catch (\ValueError $e) {
11-
echo $e->getMessage() . PHP_EOL;
11+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1212
}
1313
try {
1414
imagescale($im, 0, 1, 0);
1515
} catch (\ValueError $e) {
16-
echo $e->getMessage() . PHP_EOL;
16+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1717
}
1818
try {
1919
imagescale($im, 1, 0, 0);
2020
} catch (\ValueError $e) {
21-
echo $e->getMessage() . PHP_EOL;
21+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
2222
}
2323
imagescale($im, 1, 1, IMG_BICUBIC_FIXED);
2424
echo "OK";
2525
?>
2626
--EXPECT--
27-
imagescale(): Argument #4 ($mode) must be one of the GD_* constants
28-
imagescale(): Argument #2 ($width) must be between 1 and 2147483647
29-
imagescale(): Argument #3 ($height) must be between 1 and 2147483647
27+
ValueError: imagescale(): Argument #4 ($mode) must be one of the GD_* constants
28+
ValueError: imagescale(): Argument #2 ($width) must be between 1 and 2147483647
29+
ValueError: imagescale(): Argument #3 ($height) must be between 1 and 2147483647
3030
OK

‎ext/gd/tests/bug72709.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ try {
1010
var_dump(imagesetstyle($im, array()));
1111
}
1212
catch (\Error $ex) {
13-
echo $ex->getMessage() . "\n";
13+
echo $ex::class, ': ', $ex->getMessage(), "\n";
1414
}
1515

1616
imagesetpixel($im, 0, 0, IMG_COLOR_STYLED);
1717
?>
1818
====DONE====
1919
--EXPECT--
20-
imagesetstyle(): Argument #2 ($style) must not be empty
20+
ValueError: imagesetstyle(): Argument #2 ($style) must not be empty
2121
====DONE====

‎ext/gd/tests/bug73957.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ try {
1515
// which is not supposed to happen
1616
var_dump(imagesx($im));
1717
} catch (\ValueError $e) {
18-
echo $e->getMessage();
18+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1919
}
2020
?>
2121
--EXPECTF--
22-
imagescale(): Argument #2 ($width) must be between 1 and %d
22+
ValueError: imagescale(): Argument #2 ($width) must be between 1 and %d

‎ext/gd/tests/bug81739.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Warning: imageloadfont(): %croduct of memory allocation multiplication would exc
1919
in %s on line %d
2020

2121
Warning: imageloadfont(): Error reading font, invalid font header in %s on line %d
22-
bool(false)
22+
bool(false)

‎ext/gd/tests/colorclosest.phpt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $c = imagecolorclosest($im, 255,0,255);
1515
try {
1616
imagecolorsforindex($im, $c);
1717
} catch (ValueError $exception) {
18-
echo $exception->getMessage() . "\n";
18+
echo $exception::class, ': ', $exception->getMessage(), "\n";
1919
}
2020
$im = null;
2121

@@ -53,7 +53,7 @@ $c = imagecolorclosestalpha($im, 255,0,255,100);
5353
try {
5454
imagecolorsforindex($im, $c);
5555
} catch (ValueError $exception) {
56-
echo $exception->getMessage() . "\n";
56+
echo $exception::class, ': ', $exception->getMessage(), "\n";
5757
}
5858
$im = null;
5959

@@ -82,7 +82,7 @@ print_r(imagecolorsforindex($im, $c));
8282
?>
8383
--EXPECT--
8484
FF00FF
85-
imagecolorsforindex(): Argument #2 ($color) is out of range
85+
ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range
8686
Array
8787
(
8888
[red] => 255
@@ -105,7 +105,7 @@ Array
105105
[alpha] => 0
106106
)
107107
64FF00FF
108-
imagecolorsforindex(): Argument #2 ($color) is out of range
108+
ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range
109109
Array
110110
(
111111
[red] => 255

‎ext/gd/tests/colormatch.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ $im2 = imagecreate(5,5);
1111
try {
1212
imagecolormatch($im, $im2);
1313
} catch (ValueError $exception) {
14-
echo $exception->getMessage() . "\n";
14+
echo $exception::class, ': ', $exception->getMessage(), "\n";
1515
}
1616

1717
echo "ok\n";
1818
?>
1919
--EXPECT--
20-
imagecolormatch(): Argument #2 ($image2) must have at least one color
20+
ValueError: imagecolormatch(): Argument #2 ($image2) must have at least one color
2121
ok

‎ext/gd/tests/createfromstring.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ unlink($dir . '/p.png');
5555
try {
5656
imagecreatefromstring('');
5757
} catch (ValueError $exception) {
58-
echo $exception->getMessage() . "\n";
58+
echo $exception::class, ': ', $exception->getMessage(), "\n";
5959
}
6060
//random string > 12
6161
$im = imagecreatefromstring(' asdf jklp foo');

‎ext/gd/tests/gdimage_prevent_cloning.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ try {
99
$img_src = imagecreatetruecolor(32, 32);
1010
$img_dst = clone $img_src;
1111
} catch (Throwable $e) {
12-
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
12+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
1313
}
1414

1515
?>

0 commit comments

Comments
 (0)