Skip to content

Commit dde8bbc

Browse files
committed
test(PhpNativeHandlerTest): update name-centering assertion for 1.0 line height
nameStartY = (80 + 20) / 2 - 20 = 30.0 (was 32.0 with old 1.2 factor) Update expected Td coordinate from 32.00 to 30.00 and fix the doc comment. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 432422f commit dde8bbc

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

tests/php/Unit/Handler/SignEngine/PhpNativeHandlerTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,12 @@ public function testBuildAppearanceForElementSetsSignatureImageInGraphicOnlyMode
379379
* centred within the left half of the stamp, not pinned to leftPadding (left edge).
380380
*
381381
* Layout math for width=200, height=80, fontSize=20, name="Al":
382-
* leftHalfW = 100.0
383-
* lineWidth = strlen("Al") * (20 * 0.52) = 2 * 10.4 = 20.8
384-
* nameX = max(2.0, (100 - 20.8) / 2) = 39.6 → "39.60"
385-
* nameStartY = (80 + 24) / 2 - 20 = 32.0 → "32.00"
386-
* Old (broken) code always used leftPadding=2.0 → "2.00 32.00 Td"
382+
* leftHalfW = 100.0
383+
* lineWidth = strlen("Al") * (20 * 0.52) = 2 * 10.4 = 20.8
384+
* nameX = max(2.0, (100 - 20.8) / 2) = 39.6 → "39.60"
385+
* totalNameHeight = 1 * 20 * 1.0 = 20 (lineHeight factor = 1.0)
386+
* nameStartY = (80 + 20) / 2 - 20 = 30.0 → "30.00"
387+
* Old (broken) code always used leftPadding=2.0 → "2.00 30.00 Td"
387388
*/
388389
public function testBuildXObjectSignameAndDescriptionCentersNameInLeftHalf(): void {
389390
$handler = $this->getHandlerWithMode(SignerElementsService::RENDER_MODE_SIGNAME_AND_DESCRIPTION);
@@ -393,9 +394,9 @@ public function testBuildXObjectSignameAndDescriptionCentersNameInLeftHalf(): vo
393394
);
394395

395396
// Centred position must appear
396-
$this->assertStringContainsString('39.60 32.00 Td', $xObject->stream);
397+
$this->assertStringContainsString('39.60 30.00 Td', $xObject->stream);
397398
// Old left-aligned position must NOT appear
398-
$this->assertStringNotContainsString('2.00 32.00 Td', $xObject->stream);
399+
$this->assertStringNotContainsString('2.00 30.00 Td', $xObject->stream);
399400
}
400401

401402
public function testBuildXObjectSignameAndDescriptionWithEmptyNameOmitsNameBlock(): void {

0 commit comments

Comments
 (0)