Skip to content

Commit a9923d6

Browse files
committed
test: simplify visible stamp integration scenarios
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent d7f26b0 commit a9923d6

3 files changed

Lines changed: 331 additions & 572 deletions

File tree

tests/Integration/ExamplesOutputScenarioTest.php

Lines changed: 1 addition & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -218,189 +218,4 @@ public static function integrationRenderingScenarioProvider(): iterable
218218
'maxStreamLength' => 1800,
219219
];
220220
}
221-
222-
#[DataProvider('visibleStampExampleScenarioProvider')]
223-
public function testVisibleStampScenariosAlsoGenerateExampleArtifacts(
224-
string $kind,
225-
string $slug,
226-
?string $layout,
227-
float $width,
228-
float $height,
229-
int $expectedImageCount,
230-
array $expectedTexts,
231-
): void {
232-
$projectRoot = dirname(__DIR__, 2);
233-
$outputRoot = $projectRoot . '/build/examples/visible-stamp';
234-
$factory = new VisibleStampPreviewFactory($projectRoot);
235-
236-
if ($kind === 'phase_one') {
237-
if (!is_string($layout)) {
238-
throw new \InvalidArgumentException('Phase-one visible stamp scenario requires a layout identifier.');
239-
}
240-
241-
['result' => $result, 'pdf' => $pdf, 'previewPath' => $previewPath] = $factory->compilePhaseOneLayoutPreview(
242-
$slug,
243-
$layout,
244-
$outputRoot,
245-
);
246-
247-
self::assertSame($width, $result->resources['XObject']['Im0']['Width']);
248-
self::assertSame($height, $result->resources['XObject']['Im0']['Height']);
249-
} else {
250-
[
251-
'result' => $result,
252-
'pdf' => $pdf,
253-
'previewPath' => $previewPath,
254-
'logoPath' => $logoPath,
255-
] = $factory->compileGovBrLikePreview(
256-
$slug,
257-
$width,
258-
$height,
259-
$outputRoot,
260-
);
261-
262-
self::assertSame($logoPath, $result->resources['XObject']['Im0']['Source']);
263-
}
264-
265-
self::assertSame($expectedImageCount, count($result->resources['XObject'] ?? []));
266-
self::assertStringStartsWith('%PDF-', $pdf);
267-
self::assertStringContainsString('/Subtype /Form', $pdf);
268-
self::assertStringContainsString('/Im0 Do', $result->contentStream);
269-
self::assertFileExists($previewPath);
270-
self::assertSame($pdf, file_get_contents($previewPath));
271-
self::assertStringStartsWith($outputRoot . '/', $previewPath);
272-
273-
foreach ($expectedTexts as $expectedText) {
274-
self::assertStringContainsString($expectedText, $result->contentStream);
275-
self::assertStringContainsString($expectedText, $pdf);
276-
}
277-
}
278-
279-
/**
280-
* @return iterable<string, array{
281-
* kind: 'phase_one'|'govbr',
282-
* slug: string,
283-
* layout: string|null,
284-
* width: float,
285-
* height: float,
286-
* expectedImageCount: int,
287-
* expectedTexts: list<string>
288-
* }>
289-
*/
290-
public static function visibleStampExampleScenarioProvider(): iterable
291-
{
292-
foreach (self::visibleStampPhaseOneLayouts() as $name => $scenario) {
293-
yield 'phase one: ' . $name => [
294-
'kind' => 'phase_one',
295-
'slug' => $scenario['slug'],
296-
'layout' => $scenario['layout'],
297-
'width' => VisibleStampPreviewFactory::DEFAULT_PREVIEW_WIDTH,
298-
'height' => VisibleStampPreviewFactory::DEFAULT_PREVIEW_HEIGHT,
299-
'expectedImageCount' => $scenario['expectedImageCount'],
300-
'expectedTexts' => $scenario['expectedTexts'],
301-
];
302-
}
303-
304-
$govBr = self::govBrLikeScenario();
305-
yield 'govbr-like' => [
306-
'kind' => 'govbr',
307-
'slug' => $govBr['slug'],
308-
'layout' => null,
309-
'width' => $govBr['width'],
310-
'height' => $govBr['height'],
311-
'expectedImageCount' => $govBr['expectedImageCount'],
312-
'expectedTexts' => $govBr['expectedTexts'],
313-
];
314-
}
315-
316-
/**
317-
* @return iterable<string, array{
318-
* slug: string,
319-
* layout: string,
320-
* expectedImageCount: int,
321-
* expectedTexts: list<string>
322-
* }>
323-
*/
324-
private static function visibleStampPhaseOneLayouts(): iterable
325-
{
326-
yield 'signature and metadata at right' => [
327-
'slug' => 'signature-and-metadata-right',
328-
'layout' => 'signature_and_metadata_right',
329-
'expectedImageCount' => 2,
330-
'expectedTexts' => [
331-
'Signed with LibreSign',
332-
'admin',
333-
'Issuer: Preview Issuer',
334-
'Date: 2026-05-28T16:40:21+00:00',
335-
],
336-
];
337-
338-
yield 'label and metadata at right' => [
339-
'slug' => 'label-and-metadata-right',
340-
'layout' => 'label_and_metadata_right',
341-
'expectedImageCount' => 1,
342-
'expectedTexts' => [
343-
'admin',
344-
'Signed with LibreSign',
345-
'Issuer: Preview Issuer',
346-
'Date: 2026-05-28T16:40:21+00:00',
347-
],
348-
];
349-
350-
yield 'signature centered' => [
351-
'slug' => 'signature-centered',
352-
'layout' => 'signature_centered',
353-
'expectedImageCount' => 2,
354-
'expectedTexts' => [],
355-
];
356-
357-
yield 'metadata only at top left' => [
358-
'slug' => 'metadata-only-top-left',
359-
'layout' => 'metadata_only_top_left',
360-
'expectedImageCount' => 1,
361-
'expectedTexts' => [
362-
'Signed with LibreSign',
363-
'admin',
364-
'Issuer: Preview Issuer',
365-
'Date: 2026-05-28T16:40:21+00:00',
366-
],
367-
];
368-
369-
yield 'two columns with centered cells' => [
370-
'slug' => 'two-columns-centered-cells',
371-
'layout' => 'two_columns_centered_cells',
372-
'expectedImageCount' => 2,
373-
'expectedTexts' => [
374-
'Signed with LibreSign',
375-
'Preview Issuer',
376-
'Date:',
377-
'2026-05-28T16:40:21+00:00',
378-
],
379-
];
380-
}
381-
382-
/**
383-
* @return array{
384-
* slug: string,
385-
* width: float,
386-
* height: float,
387-
* expectedImageCount: int,
388-
* expectedTexts: list<string>
389-
* }
390-
*/
391-
private static function govBrLikeScenario(): array
392-
{
393-
return [
394-
'slug' => 'govbr-like-visible-stamp',
395-
'width' => 760.0,
396-
'height' => 210.0,
397-
'expectedImageCount' => 1,
398-
'expectedTexts' => [
399-
'Documento assinado digitalmente',
400-
'ASSINANTE DE EXEMPLO',
401-
'Data: 01/01/2026 12:00:00-0300',
402-
'Verifique em https://verificador.iti.br',
403-
],
404-
];
405-
}
406-
}
221+
}

0 commit comments

Comments
 (0)