Added security check report settings and templating

This commit is contained in:
2026-06-22 14:00:14 +02:00
parent 0b7c08ba6b
commit 7a9f8e770a
18 changed files with 1120 additions and 12 deletions

View File

@@ -4,6 +4,8 @@ namespace MintyPHP\Tests\Module\Security\Service;
use MintyPHP\Module\Security\Service\SecurityCheckProcess;
use MintyPHP\Module\Security\Service\SecurityReportPdfService;
use MintyPHP\Module\Security\Service\SecurityReportSettingsGateway;
use MintyPHP\Module\Security\Service\SecurityReportTemplateService;
use MintyPHP\Service\Branding\BrandingLogoService;
use PHPUnit\Framework\TestCase;
@@ -48,6 +50,7 @@ class SecurityReportPdfServiceTest extends TestCase
'domain_no' => 'DNS-1',
'product_name' => 'Intranet',
'product_code' => 'intranet',
'owner_name' => 'Jane Doe',
'status' => SecurityCheckProcess::STATUS_IN_PROGRESS,
'process_state' => $processState,
'tech_schema_snapshot' => $snapshot,
@@ -64,6 +67,7 @@ class SecurityReportPdfServiceTest extends TestCase
$this->assertSame('D-100', $context['customer_no']);
$this->assertSame('acme.de', $context['domain']);
$this->assertSame('Intranet', $context['product']);
$this->assertSame('Jane Doe', $context['owner']);
$this->assertNotSame('', $context['title']);
// Summary mirrors the progress math (3 tech items, 2 done).
@@ -126,4 +130,28 @@ class SecurityReportPdfServiceTest extends TestCase
$this->assertNotSame('', $pdf);
$this->assertStringStartsWith('%PDF-', $pdf);
}
public function testRenderCustomerReportPdfUsesConfiguredCustomTemplate(): void
{
$branding = $this->createMock(BrandingLogoService::class);
$branding->method('hasLogo')->willReturn(false);
$settings = $this->createMock(SecurityReportSettingsGateway::class);
$settings->method('getTemplateHtml')->willReturn(
'<!doctype html><html><body><h1>Custom {{customer_name}}</h1>{{checklist}}</body></html>'
);
$service = new SecurityReportPdfService(
new SecurityCheckProcess(),
$branding,
null,
$settings,
new SecurityReportTemplateService(),
null
);
$pdf = $service->renderCustomerReportPdf($this->enrichedCheck(), ['app_name' => 'CoreCore']);
$this->assertStringStartsWith('%PDF-', $pdf);
}
}