From a4acca4bf9b51083044b2a142585be511079b42b Mon Sep 17 00:00:00 2001 From: HorstOeko Date: Thu, 28 Mar 2024 14:41:16 +0100 Subject: [PATCH] Added moew unit tests for better test coverage --- src/ZugferdDocument.php | 1 + tests/testcases/BuilderEn16931Test.php | 41 +++++++++++++++++++ tests/testcases/BuilderExtendedTest.php | 41 +++++++++++++++++++ tests/testcases/BuilderMinimumTest.php | 41 +++++++++++++++++++ tests/testcases/DocumentTest.php | 13 ++++++ tests/testcases/ObjectHelperEn16931Test.php | 22 ++++++++++ tests/testcases/ObjectHelperExtendedTest.php | 22 ++++++++++ tests/testcases/ReaderBasicSimpleTest.php | 24 ++++++++++- .../ReaderEn16931AllowanceChargeTest.php | 24 ++++++++++- tests/testcases/ReaderEn16931Bank1Test.php | 24 ++++++++++- tests/testcases/ReaderEn16931SimpleTest.php | 24 ++++++++++- tests/testcases/ReaderExtended2Test.php | 24 ++++++++++- tests/testcases/ReaderExtendedTest.php | 24 ++++++++++- ...eaderXRechnungAttachedBinaryObjectTest.php | 24 ++++++++++- tests/testcases/ReaderXRechnungSimpleTest.php | 24 ++++++++++- 15 files changed, 365 insertions(+), 8 deletions(-) diff --git a/src/ZugferdDocument.php b/src/ZugferdDocument.php index 7238e773..ea4efca4 100644 --- a/src/ZugferdDocument.php +++ b/src/ZugferdDocument.php @@ -98,6 +98,7 @@ public function getInvoiceObject() * Create a new instance of the internal invoice object * * @return \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwl\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice + * @codeCoverageIgnore */ protected function createInvoiceObject() { diff --git a/tests/testcases/BuilderEn16931Test.php b/tests/testcases/BuilderEn16931Test.php index 1afc6656..c961e024 100644 --- a/tests/testcases/BuilderEn16931Test.php +++ b/tests/testcases/BuilderEn16931Test.php @@ -25,6 +25,29 @@ public function testDocumentProfile(): void $this->assertNotEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EN 16931 (COMFORT)', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EN 16931', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + public function testXmlGenerals(): void { $xml = $this->getXml(); @@ -2279,4 +2302,22 @@ public function testToString(): void $this->assertIsString($xmlContent); $this->assertStringStartsWith("\ngetContentAsDomDocument(); + $this->assertInstanceOf(\DOMDocument::class, $domDocument); + } + + /** + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getContentAsDomXPath + */ + public function testGetContentAsDomXPath(): void + { + $domXPath = self::$document->getContentAsDomXPath(); + $this->assertInstanceOf(\DOMXpath::class, $domXPath); + } } diff --git a/tests/testcases/BuilderExtendedTest.php b/tests/testcases/BuilderExtendedTest.php index 94eeb695..c6f272ef 100644 --- a/tests/testcases/BuilderExtendedTest.php +++ b/tests/testcases/BuilderExtendedTest.php @@ -24,6 +24,29 @@ public function testDocumentProfile(): void $this->assertEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('extended', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + public function testXmlGenerals(): void { $xml = $this->getXml(); @@ -2134,4 +2157,22 @@ public function testToString(): void $this->assertIsString($xmlContent); $this->assertStringStartsWith("\ngetContentAsDomDocument(); + $this->assertInstanceOf(\DOMDocument::class, $domDocument); + } + + /** + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getContentAsDomXPath + */ + public function testGetContentAsDomXPath(): void + { + $domXPath = self::$document->getContentAsDomXPath(); + $this->assertInstanceOf(\DOMXpath::class, $domXPath); + } } diff --git a/tests/testcases/BuilderMinimumTest.php b/tests/testcases/BuilderMinimumTest.php index b08303c7..9daba70c 100644 --- a/tests/testcases/BuilderMinimumTest.php +++ b/tests/testcases/BuilderMinimumTest.php @@ -26,6 +26,29 @@ public function testDocumentProfile(): void $this->assertNotEquals(ZugferdProfiles::PROFILE_EN16931, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('minimum', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('MINIMUM', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:factur-x.eu:1p0:minimum', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('MINIMUM', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + public function testXmlGenerals(): void { $xml = $this->getXml(); @@ -2133,4 +2156,22 @@ public function testToString(): void $this->assertIsString($xmlContent); $this->assertStringStartsWith("\ngetContentAsDomDocument(); + $this->assertInstanceOf(\DOMDocument::class, $domDocument); + } + + /** + * @covers \horstoeko\zugferd\ZugferdDocumentBuilder::getContentAsDomXPath + */ + public function testGetContentAsDomXPath(): void + { + $domXPath = self::$document->getContentAsDomXPath(); + $this->assertInstanceOf(\DOMXpath::class, $domXPath); + } } diff --git a/tests/testcases/DocumentTest.php b/tests/testcases/DocumentTest.php index 0ea8bbde..8ab8d1d3 100644 --- a/tests/testcases/DocumentTest.php +++ b/tests/testcases/DocumentTest.php @@ -97,6 +97,19 @@ public function testDocumentInternals(): void $this->assertNotNull($property->getValue($doc)); } + /** + * @covers \horstoeko\zugferd\ZugferdDocument::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocument::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocument::getObjectHelper + */ + public function testDocumentGetters(): void + { + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EXTENDED); + $this->assertNotNull($doc->getInvoiceObject()); + $this->assertNotNull($doc->getSerializer()); + $this->assertNotNull($doc->getObjectHelper()); + } + /** * Access to private properties * diff --git a/tests/testcases/ObjectHelperEn16931Test.php b/tests/testcases/ObjectHelperEn16931Test.php index 482c7f99..f0ba3bce 100644 --- a/tests/testcases/ObjectHelperEn16931Test.php +++ b/tests/testcases/ObjectHelperEn16931Test.php @@ -20,6 +20,28 @@ public static function setUpBeforeClass(): void self::$objectHelper = new ZugferdObjectHelper(ZugferdProfiles::PROFILE_EN16931); } + /** + * @covers \horstoeko\zugferd\ZugferdObjectHelper::getDocumentCodeType + */ + public function testGetDocumentCodeTypeEmpty(): void + { + $codeType = self::$objectHelper->getDocumentCodeType(); + $this->assertNull($codeType); + } + + /** + * @covers \horstoeko\zugferd\ZugferdObjectHelper::getDocumentCodeType + */ + public function testGetDocumentCodeTypeNotEmpty(): void + { + /** + * @var \horstoeko\zugferd\entities\en16931\qdt\DocumentCodeType + */ + $codeType = self::$objectHelper->getDocumentCodeType("380"); + $this->assertNotNull($codeType); + $this->assertEquals("380", $codeType->value()); + } + /** * @covers \horstoeko\zugferd\ZugferdObjectHelper::getIdType */ diff --git a/tests/testcases/ObjectHelperExtendedTest.php b/tests/testcases/ObjectHelperExtendedTest.php index a00b02ce..eb4cb768 100644 --- a/tests/testcases/ObjectHelperExtendedTest.php +++ b/tests/testcases/ObjectHelperExtendedTest.php @@ -20,6 +20,28 @@ public static function setUpBeforeClass(): void self::$objectHelper = new ZugferdObjectHelper(ZugferdProfiles::PROFILE_EXTENDED); } + /** + * @covers \horstoeko\zugferd\ZugferdObjectHelper::getDocumentCodeType + */ + public function testGetDocumentCodeTypeEmpty(): void + { + $codeType = self::$objectHelper->getDocumentCodeType(); + $this->assertNull($codeType); + } + + /** + * @covers \horstoeko\zugferd\ZugferdObjectHelper::getDocumentCodeType + */ + public function testGetDocumentCodeTypeNotEmpty(): void + { + /** + * @var \horstoeko\zugferd\entities\extended\qdt\DocumentCodeType + */ + $codeType = self::$objectHelper->getDocumentCodeType("380"); + $this->assertNotNull($codeType); + $this->assertEquals("380", $codeType->value()); + } + /** * @covers \horstoeko\zugferd\ZugferdObjectHelper::getIdType */ diff --git a/tests/testcases/ReaderBasicSimpleTest.php b/tests/testcases/ReaderBasicSimpleTest.php index 0475c06a..ebc62eff 100644 --- a/tests/testcases/ReaderBasicSimpleTest.php +++ b/tests/testcases/ReaderBasicSimpleTest.php @@ -27,6 +27,29 @@ public function testDocumentProfile(): void $this->assertNotEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('basic', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('BASIC', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('BASIC', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -42,7 +65,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderEn16931AllowanceChargeTest.php b/tests/testcases/ReaderEn16931AllowanceChargeTest.php index f68bdddd..318ec8e8 100644 --- a/tests/testcases/ReaderEn16931AllowanceChargeTest.php +++ b/tests/testcases/ReaderEn16931AllowanceChargeTest.php @@ -27,6 +27,29 @@ public function testDocumentProfile(): void $this->assertNotEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EN 16931 (COMFORT)', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EN 16931', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -42,7 +65,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderEn16931Bank1Test.php b/tests/testcases/ReaderEn16931Bank1Test.php index 1fa57dd0..f4d4c6a1 100644 --- a/tests/testcases/ReaderEn16931Bank1Test.php +++ b/tests/testcases/ReaderEn16931Bank1Test.php @@ -28,6 +28,29 @@ public function testDocumentProfile(): void $this->assertNotEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EN 16931 (COMFORT)', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EN 16931', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -43,7 +66,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderEn16931SimpleTest.php b/tests/testcases/ReaderEn16931SimpleTest.php index 31f95e0f..932dd227 100644 --- a/tests/testcases/ReaderEn16931SimpleTest.php +++ b/tests/testcases/ReaderEn16931SimpleTest.php @@ -27,6 +27,29 @@ public function testDocumentProfile(): void $this->assertNotEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EN 16931 (COMFORT)', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EN 16931', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -42,7 +65,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderExtended2Test.php b/tests/testcases/ReaderExtended2Test.php index b0568941..69cd278f 100644 --- a/tests/testcases/ReaderExtended2Test.php +++ b/tests/testcases/ReaderExtended2Test.php @@ -27,6 +27,29 @@ public function testDocumentProfile(): void $this->assertEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('extended', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -42,7 +65,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderExtendedTest.php b/tests/testcases/ReaderExtendedTest.php index 8e4af3c1..a81fb2ba 100644 --- a/tests/testcases/ReaderExtendedTest.php +++ b/tests/testcases/ReaderExtendedTest.php @@ -27,6 +27,29 @@ public function testDocumentProfile(): void $this->assertEquals(ZugferdProfiles::PROFILE_EXTENDED, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('extended', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('factur-x.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -42,7 +65,6 @@ public function testDocumentGenerals(): void $this->assertEquals("KOSTENRECHNUNG", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderXRechnungAttachedBinaryObjectTest.php b/tests/testcases/ReaderXRechnungAttachedBinaryObjectTest.php index 14865617..12233a1d 100644 --- a/tests/testcases/ReaderXRechnungAttachedBinaryObjectTest.php +++ b/tests/testcases/ReaderXRechnungAttachedBinaryObjectTest.php @@ -29,6 +29,29 @@ public function testDocumentProfile(): void $this->assertEquals(ZugferdProfiles::PROFILE_XRECHNUNG_2, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('XRECHNUNG', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('xrechnung.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EN 16931', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -44,7 +67,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /** diff --git a/tests/testcases/ReaderXRechnungSimpleTest.php b/tests/testcases/ReaderXRechnungSimpleTest.php index 15f9d396..3538c758 100644 --- a/tests/testcases/ReaderXRechnungSimpleTest.php +++ b/tests/testcases/ReaderXRechnungSimpleTest.php @@ -28,6 +28,29 @@ public function testDocumentProfile(): void $this->assertEquals(ZugferdProfiles::PROFILE_XRECHNUNG, self::$document->getProfileId()); } + /** + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getInvoiceObject + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getSerializer + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getObjectHelper + * @covers \horstoeko\zugferd\ZugferdDocumentReader::getProfileDefinitionParameter + */ + public function testDocumentGetters(): void + { + $this->assertNotNull(self::$document->getInvoiceObject()); + $this->assertNotNull(self::$document->getSerializer()); + $this->assertNotNull(self::$document->getObjectHelper()); + $this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name')); + $this->assertEquals('XRECHNUNG', self::$document->getProfileDefinitionParameter('altname')); + $this->assertEquals('urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_1.2', self::$document->getProfileDefinitionParameter('contextparameter')); + $this->assertEquals('xrechnung.xml', self::$document->getProfileDefinitionParameter('attachmentfilename')); + $this->assertEquals('EN 16931', self::$document->getProfileDefinitionParameter('xmpname')); + $this->expectNoticeOrWarningExt( + function () { + self::$document->getProfileDefinitionParameter('unknownparameter'); + } + ); + } + /** * @covers \horstoeko\zugferd\ZugferdDocumentReader::getDocumentInformation */ @@ -43,7 +66,6 @@ public function testDocumentGenerals(): void $this->assertEquals("", $documentname); $this->assertEquals("", $documentlanguage); $this->assertNull($effectiveSpecifiedPeriod); - $this->assertNotNull(self::$document->getInvoiceObject()); } /**