Skip to content

Commit c9d3714

Browse files
mathiasgrimmclaude
andcommitted
Lock six-argument ImageResult construction
Adds a test asserting the pre-3.1 six-argument constructor still works and defaults psnr to null, so the additive parameter cannot silently become a breaking change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 23c490d commit c9d3714

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/ClientTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use MathiasGrimm\GlimpsePhp\ForbiddenException;
99
use MathiasGrimm\GlimpsePhp\ImageFormat;
1010
use MathiasGrimm\GlimpsePhp\ImageInfo;
11+
use MathiasGrimm\GlimpsePhp\ImageResult;
1112
use MathiasGrimm\GlimpsePhp\RateLimitException;
1213
use MathiasGrimm\GlimpsePhp\SizeEstimate;
1314
use MathiasGrimm\GlimpsePhp\Tests\Fixtures\Images;
@@ -69,6 +70,14 @@ function client(Factory $http, Closure|string|null $token = 'test-token', string
6970
expect(client($http)->optimize(Images::png())->psnr)->toBe(42.0);
7071
});
7172

73+
test('the six-argument constructor stays valid and defaults psnr to null', function () {
74+
// Locks backward compatibility: callers built against pre-3.1 must keep
75+
// working without passing psnr.
76+
$result = new ImageResult('bytes', 'jpg', 'image/jpeg', 100, 20, 10);
77+
78+
expect($result->psnr)->toBeNull();
79+
});
80+
7281
test('convert sends optimize and quality when given', function () {
7382
$http = fakeHttp(['*/v1/convert' => Factory::response(fakeTransformResponse())]);
7483

0 commit comments

Comments
 (0)