Skip to content

Commit

Permalink
Added Tests for MINIMUM-Profile, Fix YAML Definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed May 16, 2023
1 parent 0ab1a9b commit 2432b4f
Show file tree
Hide file tree
Showing 12 changed files with 3,296 additions and 6 deletions.
2 changes: 2 additions & 0 deletions build/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
<file>../tests/testcases/ReaderXRechnungAttachedBinaryObjectTest.php</file>
</testsuite>
<testsuite name="Builder">
<file>../tests/testcases/BuilderMinimumTest.php</file>
<file>../tests/testcases/BuilderEn16931Test.php</file>
<file>../tests/testcases/BuilderExtendedTest.php</file>
</testsuite>
<testsuite name="PDFReader">
<file>../tests/testcases/PdfReaderMinimumSimpleTest.php</file>
<file>../tests/testcases/PdfReaderEn16931AllowanceChargeTest.php</file>
<file>../tests/testcases/PdfReaderEn16931SimpleTest.php</file>
<file>../tests/testcases/PdfReaderExtendedTest.php</file>
Expand Down
2 changes: 1 addition & 1 deletion src/ZugferdDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function setDocumentInformation(string $documentno, string $documenttypec
{
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "setID", $this->objectHelper->getIdType($documentno));
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "setName", $this->objectHelper->getTextType($documentname));
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "setTypeCode", $this->objectHelper->getCodeType($documenttypecode));
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "setTypeCode", $this->objectHelper->getDocumentCodeType($documenttypecode));
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "setIssueDateTime", $this->objectHelper->getDateTimeType($documentdate));
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "addToLanguageID", $this->objectHelper->getIdType($documentlanguage));
$this->objectHelper->tryCall($this->invoiceObject->getExchangedDocument(), "setEffectiveSpecifiedPeriod", $this->objectHelper->getSpecifiedPeriodType(null, null, $effectiveSpecifiedPeriod, null));
Expand Down
15 changes: 15 additions & 0 deletions src/ZugferdObjectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ public function __construct(int $profile)
$this->profiledef = ZugferdProfiles::PROFILEDEF[$profile];
}

/**
* Creates an instance of DocumentCodeType
*
* @param string|null $value
* @return object|null
*/
public function getDocumentCodeType(?string $value = null): ?object
{
if (self::isAllNullOrEmpty(func_get_args())) {
return null;
}

return $this->createClassInstance('qdt\DocumentCodeType', $value);
}

/**
* Creates an instance of IDType
*
Expand Down
2 changes: 1 addition & 1 deletion src/yaml/minimum/ram/ExchangedDocumentType.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ horstoeko\zugferd\entities\minimum\ram\ExchangedDocumentType:
accessor:
getter: getTypeCode
setter: setTypeCode
type: string
type: horstoeko\zugferd\entities\minimum\qdt\DocumentCodeType
issueDateTime:
expose: true
access_type: public_method
Expand Down
2 changes: 1 addition & 1 deletion src/yaml/minimum/ram/HeaderTradeAgreementType.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ horstoeko\zugferd\entities\minimum\ram\HeaderTradeAgreementType:
accessor:
getter: getBuyerReference
setter: setBuyerReference
type: string
type: horstoeko\zugferd\entities\minimum\udt\TextType
sellerTradeParty:
expose: true
access_type: public_method
Expand Down
2 changes: 1 addition & 1 deletion src/yaml/minimum/ram/HeaderTradeSettlementType.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ horstoeko\zugferd\entities\minimum\ram\HeaderTradeSettlementType:
accessor:
getter: getInvoiceCurrencyCode
setter: setInvoiceCurrencyCode
type: string
type: horstoeko\zugferd\entities\minimum\qdt\CurrencyCodeType
specifiedTradeSettlementHeaderMonetarySummation:
expose: true
access_type: public_method
Expand Down
3 changes: 2 additions & 1 deletion src/yaml/minimum/ram/TradeAddressType.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ horstoeko\zugferd\entities\minimum\ram\TradeAddressType:
accessor:
getter: getCountryID
setter: setCountryID
type: string
type: horstoeko\zugferd\entities\minimum\qdt\CountryIDType

2 changes: 1 addition & 1 deletion src/yaml/minimum/ram/TradePartyType.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ horstoeko\zugferd\entities\minimum\ram\TradePartyType:
accessor:
getter: getName
setter: setName
type: string
type: horstoeko\zugferd\entities\minimum\udt\TextType
specifiedLegalOrganization:
expose: true
access_type: public_method
Expand Down
Binary file added tests/assets/Facture_F20220027_MINIMUM.pdf
Binary file not shown.
2,102 changes: 2,102 additions & 0 deletions tests/testcases/BuilderMinimumTest.php

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tests/testcases/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@

class DocumentTest extends TestCase
{
/**
* @covers \horstoeko\zugferd\ZugferdDocument::__construct
*/
public function testDocumentCreationMinimum(): void
{
$doc = new ZugferdDocument(ZugferdProfiles::PROFILE_MINIMUM);
$this->assertNotNull($doc);
$this->assertEquals(ZugferdProfiles::PROFILE_MINIMUM, $doc->profileId);
$this->assertArrayHasKey("contextparameter", $doc->profileDefinition);
$this->assertArrayHasKey("name", $doc->profileDefinition);
$this->assertEquals("urn:factur-x.eu:1p0:minimum", $doc->profileDefinition["contextparameter"]);
$this->assertEquals("minimum", $doc->profileDefinition["name"]);
}

/**
* @covers \horstoeko\zugferd\ZugferdDocument::__construct
*/
Expand Down
Loading

0 comments on commit 2432b4f

Please sign in to comment.