Skip to content

Commit 951d680

Browse files
committed
test(JSignPdfHandlerTest): regression for empty signature image with background
Add providerSignAffectedParams case: GRAPHIC_AND_DESCRIPTION render mode with a background image but no user signature (empty imagePath). Expects --bg-path with background only and no --img-path, verifying the Imagick crash guard introduced in JSignPdfHandler. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3b1eac5 commit 951d680

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/php/Unit/Handler/SignEngine/JSignPdfHandlerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,27 @@ public static function providerSignAffectedParams(): array {
468468
'hashAlgorithm' => '',
469469
'params' => '-a -kst PKCS12 --l2-text "aaaaa" -V -pg 2 -llx 10 -lly 20 -urx 30 -ury 40 --render-mode GRAPHIC_AND_DESCRIPTION --img-path text_image.png --hash-algorithm SHA256'
470470
],
471+
// Regression: background with GRAPHIC_AND_DESCRIPTION but NO user signature image.
472+
// Before the fix, mergeBackgroundWithSignature('...', '') crashed with new Imagick('').
473+
// Now the background is used directly and no --img-path is emitted.
474+
'GRAPHIC_AND_DESCRIPTION with background but no signature image: bg-path = background, no img-path' => [
475+
'visibleElements' => [self::getElement([
476+
'page' => 2,
477+
'llx' => 10,
478+
'lly' => 20,
479+
'urx' => 30,
480+
'ury' => 40,
481+
], '')], // empty imagePath — clickToSign scenario
482+
'signatureWidth' => 20,
483+
'signatureHeight' => 20,
484+
'template' => 'aaaaa',
485+
'signatureBackgroundType' => 'default',
486+
'renderMode' => SignerElementsService::RENDER_MODE_GRAPHIC_AND_DESCRIPTION,
487+
'templateFontSize' => 10,
488+
'pdfContent' => '%PDF-1.6',
489+
'hashAlgorithm' => '',
490+
'params' => '-a -kst PKCS12 --l2-text "aaaaa" -V -pg 2 -llx 10 -lly 20 -urx 30 -ury 40 --render-mode GRAPHIC_AND_DESCRIPTION --bg-path background.png --hash-algorithm SHA256'
491+
],
471492
'background without template: bg-path = merged with signature, without img-path' => [
472493
'visibleElements' => [self::getElement([
473494
'page' => 2,

0 commit comments

Comments
 (0)