diff --git a/tests/assets/cii/3_cii_technical_1.xml b/tests/assets/cii/3_cii_technical_1.xml index 0e33598..d3e5921 100644 --- a/tests/assets/cii/3_cii_technical_1.xml +++ b/tests/assets/cii/3_cii_technical_1.xml @@ -187,9 +187,11 @@ 58 - DE75512108001245126199 + + [BIC] + 58 diff --git a/tests/testcases/CiiToUblTechnical1Test.php b/tests/testcases/CiiToUblTechnical1Test.php index e07dc29..e9c6ad5 100644 --- a/tests/testcases/CiiToUblTechnical1Test.php +++ b/tests/testcases/CiiToUblTechnical1Test.php @@ -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); diff --git a/tests/traits/HandlesXmlTests.php b/tests/traits/HandlesXmlTests.php index bc08c5f..efa81ab 100644 --- a/tests/traits/HandlesXmlTests.php +++ b/tests/traits/HandlesXmlTests.php @@ -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 *