Skip to content

Commit

Permalink
Allow save generated test xml to buildlogs
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Nov 8, 2024
1 parent 631fec5 commit b5c0a46
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ _backup*
/build/pdepend/
/build/phpdox/
/build/phpdoc/
/build/xmlresults/
/*.phar
/composer.lock
/examples/*.xml
Expand Down
3 changes: 2 additions & 1 deletion tests/testcases/UblToCiiSimple2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function testLoadAndConvert(): void
{
self::$document = XmlConverterUblToCii::fromFile(dirname(__FILE__) . "/../assets/ubl/2_ubl_simple.xml")->convert();
$this->assertNotNull(self::$document);
$this->assertNotFalse($this->saveFinalXmlToBuildResults('2_ubl_simple_as_cii.xml'));
}

public function testDocumentGeneral(): void
Expand Down Expand Up @@ -232,7 +233,7 @@ public function testSellerTaxRepresentativeTradeParty(): void
$this->assertXPathValueWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:Name', 0, 'Dick Panama');
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:Description', 0);
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedLegalOrganization/ram:ID', 0);
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedLegalOrganization/ram:TradingBusinessName', 0, 'Buyco');
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedLegalOrganization/ram:TradingBusinessName', 0);
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedLegalOrganization/ram:PostalTradeAddress/ram:PostcodeCode', 0);
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedLegalOrganization/ram:PostalTradeAddress/ram:LineOne', 0);
$this->assertXPathNotExistsWithIndex('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedLegalOrganization/ram:PostalTradeAddress/ram:LineTwo', 0);
Expand Down
1 change: 1 addition & 0 deletions tests/testcases/UblToCiiSimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function testLoadAndConvert(): void
{
self::$document = XmlConverterUblToCii::fromFile(dirname(__FILE__) . "/../assets/ubl/1_ubl_simple.xml")->convert();
$this->assertNotNull(self::$document);
$this->assertNotFalse($this->saveFinalXmlToBuildResults('1_ubl_simple_as_cii.xml'));
}

public function testDocumentGeneral(): void
Expand Down
22 changes: 21 additions & 1 deletion tests/traits/HandlesXmlTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,30 @@ protected function assertXPathNotExistsWithIndex(string $xpath, int $index)
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::writeFile
* Write debug file
*
* @return void
*/
public function debugWriteFile(): void
{
self::$document->saveXmlFile(getcwd() . "/myfile_dbg.xml");
}

/**
* Save generated XML to buildlogs
*
* @param string $filename
* @return int|false
*/
public function saveFinalXmlToBuildResults(string $filename)
{
$buildDir = dirname(__FILE__) . '/../../build';
$buildXmlResultDir = $buildDir . '/xmlresults';

if (!is_dir($buildXmlResultDir)) {
@mkdir($buildXmlResultDir);
}

return self::$document->saveXmlFile($buildXmlResultDir . '/' . $filename);
}
}

0 comments on commit b5c0a46

Please sign in to comment.