Skip to content

Commit

Permalink
Improved technical testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
ruff committed Jul 31, 2024
1 parent 4f5ea76 commit c422802
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/assets/cii/3_cii_technical_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>58</ram:TypeCode>
<ram:PayeePartyCreditorFinancialAccount>
<!-- dies ist eine nicht existerende aber valide IBAN als test dummy -->
<ram:IBANID>DE75512108001245126199</ram:IBANID>
</ram:PayeePartyCreditorFinancialAccount>
<ram:PayeeSpecifiedCreditorFinancialInstitution>
<ram:BICID>[BIC]</ram:BICID>
</ram:PayeeSpecifiedCreditorFinancialInstitution>
</ram:SpecifiedTradeSettlementPaymentMeans>
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>58</ram:TypeCode>
Expand Down
3 changes: 1 addition & 2 deletions tests/testcases/CiiToUblTechnical1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public function testPaymentMeans(): void
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:CardAccount/cbc:HolderName', 0);
$this->assertXPathValueWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PayeeFinancialAccount/cbc:ID', 0, 'DE75512108001245126199');
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PayeeFinancialAccount/cbc:Name', 0);
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch', 0);
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cbc:ID', 0);
$this->assertXPathValueContainsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cbc:ID', 0, '[BIC]');
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PaymentMandate', 0);
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PaymentMandate/cbc:ID', 0);
$this->assertXPathNotExistsWithIndex('/ubl:Invoice/cac:PaymentMeans/cac:PaymentMandate/cac:PayerFinancialAccount', 0);
Expand Down
16 changes: 16 additions & 0 deletions tests/traits/HandlesXmlTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ protected function assertXPathValueStartsWithIndex(string $xpath, int $index, st
$this->assertEquals($expected, substr($xmlvalue[$index], 0, strlen($expected)));
}

/**
* Assert a xpath with $expected value in a multiple element resultset
*
* @param string $xpath
* @param integer $index
* @param string $expected
* @return void
*/
protected function assertXPathValueContainsWithIndex(string $xpath, int $index, string $expected): void
{
$xml = $this->getXml();
$xmlvalue = $xml->xpath($xpath);
$this->assertArrayHasKey($index, $xmlvalue);
$this->assertStringContainsString($expected, $xmlvalue[$index]);
}

/**
* Assert a xpath with $expected value and an expected attribute value
*
Expand Down

0 comments on commit c422802

Please sign in to comment.