Skip to content

Commit

Permalink
[ENH] Added tests for deterministic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Dec 9, 2024
1 parent 9aaebf3 commit d1f0782
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/testcases/PdfBuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function testPdfMetaData(): void
$this->assertEquals("Lieferant GmbH", $pdfDetails["dc:creator"]);
$this->assertEquals("FacturX/ZUGFeRD Invoice 471102 dated 2018-03-05 issued by Lieferant GmbH", $pdfDetails["dc:description"]);
$this->assertStringContainsString('Factur-X PHP library', $pdfDetails["xmp:creatortool"]);
$this->assertEquals("2018-03-05T00:00:00+00:00", $pdfDetails["xmp:createdate"]);
$this->assertStringContainsString("2018-03-05", $pdfDetails["xmp:createdate"]);
$this->assertStringContainsString(date("Y-m-d"), $pdfDetails["xmp:modifydate"]);
}

Expand Down Expand Up @@ -527,4 +527,48 @@ public function testAttachAdditionalFileByContentAllValid(): void
$this->assertEquals("EmbeddedFile", $pdfFilespecDetailsEF_UF["Type"]);
$this->assertEquals(195, $pdfFilespecDetailsEF_UF["Length"]);
}

public function testDeterministicMode(): void
{
$pdfBuilder = new ZugferdDocumentPdfBuilder(self::$document, self::$sourcePdfFilename);
$pdfBuilder->setDeterministicModeEnabled(true);
$pdfBuilder->generateDocument();
$pdfBuilder->saveDocument(self::$destPdfFilename);

$pdfParser = new PdfParser();
$pdfParsed = $pdfParser->parseFile(self::$destPdfFilename);
$pdfDetails = $pdfParsed->getDetails();

$this->assertIsArray($pdfDetails);
$this->assertArrayHasKey("Producer", $pdfDetails);
$this->assertArrayHasKey("CreationDate", $pdfDetails);
$this->assertArrayHasKey("Pages", $pdfDetails);
$this->assertArrayHasKey("fx:documenttype", $pdfDetails);
$this->assertArrayHasKey("fx:documentfilename", $pdfDetails);
$this->assertArrayHasKey("fx:version", $pdfDetails);
$this->assertArrayHasKey("fx:conformancelevel", $pdfDetails);
$this->assertArrayHasKey("pdfaid:part", $pdfDetails);
$this->assertArrayHasKey("pdfaid:conformance", $pdfDetails);
$this->assertArrayHasKey("dc:title", $pdfDetails);
$this->assertArrayHasKey("dc:creator", $pdfDetails);
$this->assertArrayHasKey("dc:description", $pdfDetails);
$this->assertArrayHasKey("xmp:creatortool", $pdfDetails);
$this->assertArrayHasKey("xmp:createdate", $pdfDetails);
$this->assertArrayHasKey("xmp:modifydate", $pdfDetails);
$this->assertStringContainsString('FPDF', $pdfDetails["Producer"]);
$this->assertStringContainsString('2000-01-01', $pdfDetails["CreationDate"]);
$this->assertEquals("1", $pdfDetails["Pages"]);
$this->assertEquals("INVOICE", $pdfDetails["fx:documenttype"]);
$this->assertEquals("factur-x.xml", $pdfDetails["fx:documentfilename"]);
$this->assertEquals("1.0", $pdfDetails["fx:version"]);
$this->assertEquals("EN 16931", $pdfDetails["fx:conformancelevel"]);
$this->assertEquals("3", $pdfDetails["pdfaid:part"]);
$this->assertEquals("B", $pdfDetails["pdfaid:conformance"]);
$this->assertEquals("Lieferant GmbH : Invoice 471102", $pdfDetails["dc:title"]);
$this->assertEquals("Lieferant GmbH", $pdfDetails["dc:creator"]);
$this->assertEquals("FacturX/ZUGFeRD Invoice 471102 dated 2018-03-05 issued by Lieferant GmbH", $pdfDetails["dc:description"]);
$this->assertStringContainsString('Factur-X PHP library', $pdfDetails["xmp:creatortool"]);
$this->assertStringContainsString('2000-01-01', $pdfDetails["xmp:createdate"]);
$this->assertStringContainsString('2000-01-01', $pdfDetails["xmp:modifydate"]);
}
}

0 comments on commit d1f0782

Please sign in to comment.