From 3fca94c90f9133732a4203036e031b355bd66573 Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Thu, 1 Aug 2024 14:33:21 +0200 Subject: [PATCH 1/6] feat: Add FWAV, INFO, ITAV, ITBD and XPCD balance types --- src/DTO/Balance.php | 35 +++++++++++++++++++++++++++++++++++ src/Decoder/Record.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/src/DTO/Balance.php b/src/DTO/Balance.php index d068de1..86dd2d2 100644 --- a/src/DTO/Balance.php +++ b/src/DTO/Balance.php @@ -17,6 +17,16 @@ class Balance public const TYPE_CLOSING_AVAILABLE = 'closing_available'; + public const TYPE_FORWARD_AVAILABLE = 'forward_available'; + + public const TYPE_INFORMATION = 'information'; + + public const TYPE_INTERIM = 'interim'; + + public const TYPE_INTERIM_AVAILABLE = 'interim_available'; + + public const TYPE_EXPECTED_CREDIT = 'expected_credit'; + private Money $amount; private string $type; @@ -64,4 +74,29 @@ public static function closingAvailable(Money $amount, DateTimeImmutable $date): { return new self(self::TYPE_CLOSING_AVAILABLE, $amount, $date); } + + public static function forwardAvailable(Money $amount, DateTimeImmutable $date): self + { + return new self(self::TYPE_FORWARD_AVAILABLE, $amount, $date); + } + + public static function information(Money $amount, DateTimeImmutable $date): self + { + return new self(self::TYPE_INFORMATION, $amount, $date); + } + + public static function interim(Money $amount, DateTimeImmutable $date): self + { + return new self(self::TYPE_INTERIM, $amount, $date); + } + + public static function interimAvailable(Money $amount, DateTimeImmutable $date): self + { + return new self(self::TYPE_INTERIM_AVAILABLE, $amount, $date); + } + + public static function expectedCredit(Money $amount, DateTimeImmutable $date): self + { + return new self(self::TYPE_EXPECTED_CREDIT, $amount, $date); + } } diff --git a/src/Decoder/Record.php b/src/Decoder/Record.php index b468aa4..ff66924 100644 --- a/src/Decoder/Record.php +++ b/src/Decoder/Record.php @@ -68,6 +68,42 @@ public function addBalances(RecordWithBalances $record, SimpleXMLElement $xmlRec $date )); + break; + case 'FWAV': + $record->addBalance(DTO\Balance::forwardAvailable( + $money, + $date + )); + + break; + case 'INFO': + $record->addBalance(DTO\Balance::information( + $money, + $date + )); + + break; + case 'ITAV': + $record->addBalance(DTO\Balance::interimAvailable( + $money, + $date + )); + + break; + case 'ITDB': + $record->addBalance(DTO\Balance::interim( + $money, + $date + )); + + break; + + case 'XPCD': + $record->addBalance(DTO\Balance::expectedCredit( + $money, + $date + )); + break; default: break; From cf44ab7e24fbf1381790d5127a53696061ea214d Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Mon, 5 Aug 2024 15:49:55 +0200 Subject: [PATCH 2/6] test: Add test for CAMT 053.001.02 with all available balance types --- src/Decoder/Record.php | 2 +- test/Unit/RegressionTest.php | 1 + test/data/camt053.v2.all-balance-types.json | 328 ++++++++++++++++++++ test/data/camt053.v2.all-balance-types.xml | 200 ++++++++++++ 4 files changed, 530 insertions(+), 1 deletion(-) create mode 100644 test/data/camt053.v2.all-balance-types.json create mode 100644 test/data/camt053.v2.all-balance-types.xml diff --git a/src/Decoder/Record.php b/src/Decoder/Record.php index ff66924..a3d4570 100644 --- a/src/Decoder/Record.php +++ b/src/Decoder/Record.php @@ -90,7 +90,7 @@ public function addBalances(RecordWithBalances $record, SimpleXMLElement $xmlRec )); break; - case 'ITDB': + case 'ITBD': $record->addBalance(DTO\Balance::interim( $money, $date diff --git a/test/Unit/RegressionTest.php b/test/Unit/RegressionTest.php index b864d6c..a5d335a 100644 --- a/test/Unit/RegressionTest.php +++ b/test/Unit/RegressionTest.php @@ -68,6 +68,7 @@ public static function providerRegression(): iterable yield ['test/data/camt053.v2.minimal.ultimate.xml']; yield ['test/data/camt053.v2.minimal.xml']; yield ['test/data/camt053.v2.multi.statement.xml']; + yield ['test/data/camt053.v2.all-balance-types.xml']; yield ['test/data/camt053.v3.xml']; yield ['test/data/camt053.v4.xml']; yield ['test/data/camt053.v8.xml']; diff --git a/test/data/camt053.v2.all-balance-types.json b/test/data/camt053.v2.all-balance-types.json new file mode 100644 index 0000000..f37bd3d --- /dev/null +++ b/test/data/camt053.v2.all-balance-types.json @@ -0,0 +1,328 @@ +{ + "__CLASS__": "Genkgo\\Camt\\DTO\\Message", + "getEntries": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Entry", + "getAccountServicerReference": null, + "getAdditionalInfo": "", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "885", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getBankTransactionCode": { + "__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode", + "getDomain": null, + "getProprietary": { + "__CLASS__": "Genkgo\\Camt\\DTO\\ProprietaryBankTransactionCode", + "getCode": "544", + "getIssuer": "" + } + }, + "getBatchPaymentId": null, + "getBookingDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2014-12-31T00:00:00+00:00" + }, + "getCharges": null, + "getCreditDebitIndicator": "CRDT", + "getIndex": 0, + "getRecord": { + "__CLASS__": "Genkgo\\Camt\\Camt053\\DTO\\Statement", + "getAccount": { + "__CLASS__": "Genkgo\\Camt\\DTO\\OtherAccount", + "getIdentification": "CH2801234000123456789", + "getIssuer": null, + "getSchemeName": null + }, + "getAdditionalInformation": "Additional Information", + "getBalances": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "101", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-21T00:00:00+00:00" + }, + "getType": "opening" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "202", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-21T00:00:00+00:00" + }, + "getType": "opening" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "303", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-22T00:00:00+00:00" + }, + "getType": "opening_available" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "404", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-22T00:00:00+00:00" + }, + "getType": "closing" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "505", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-23T00:00:00+00:00" + }, + "getType": "closing_available" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "606", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-26T00:00:00+00:00" + }, + "getType": "forward_available" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "707", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-27T00:00:00+00:00" + }, + "getType": "information" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "808", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-28T00:00:00+00:00" + }, + "getType": "interim_available" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "909", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-21T00:00:00+00:00" + }, + "getType": "interim" + }, + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "1010", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "EUR" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-21T00:00:00+00:00" + }, + "getType": "expected_credit" + } + ], + "getCopyDuplicateIndicator": null, + "getCreatedOn": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-21T23:00:00+00:00" + }, + "getElectronicSequenceNumber": "315", + "getEntries": [ + "__RECURSIVITY__" + ], + "getFromDate": null, + "getId": "CAMT0532015012200001", + "getLegalSequenceNumber": null, + "getPagination": null, + "getToDate": null + }, + "getReference": null, + "getReversalIndicator": false, + "getStatus": "BOOK", + "getTransactionDetail": { + "__CLASS__": "Genkgo\\Camt\\DTO\\EntryTransactionDetail", + "getAdditionalTransactionInformation": null, + "getAmount": null, + "getAmountDetails": null, + "getBankTransactionCode": { + "__CLASS__": "Genkgo\\Camt\\DTO\\BankTransactionCode", + "getDomain": null, + "getProprietary": { + "__CLASS__": "Genkgo\\Camt\\DTO\\ProprietaryBankTransactionCode", + "getCode": "544", + "getIssuer": "" + } + }, + "getCharges": null, + "getCreditDebitIndicator": "CRDT", + "getReference": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Reference", + "getAccountOwnerTransactionId": null, + "getAccountServicerReference": null, + "getAccountServicerTransactionId": null, + "getChequeNumber": null, + "getClearingSystemReference": null, + "getEndToEndId": "000000001", + "getInstructionId": null, + "getMandateId": null, + "getMarketInfrastructureTransactionId": null, + "getMessageId": null, + "getPaymentInformationId": null, + "getProcessingId": null, + "getProprietaries": [], + "getTransactionId": null, + "getUuidEndToEndReference": null + }, + "getRelatedAgent": null, + "getRelatedAgents": [], + "getRelatedDates": null, + "getRelatedParties": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\RelatedParty", + "getAccount": { + "__CLASS__": "Genkgo\\Camt\\DTO\\IbanAccount", + "getIban": { + "__CLASS__": "Genkgo\\Camt\\Iban", + "getIban": "NL56AGDH9619008421" + }, + "getIdentification": "NL56AGDH9619008421" + }, + "getRelatedPartyType": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Creditor", + "getAddress": { + "__CLASS__": "Genkgo\\Camt\\DTO\\Address", + "getAddressLines": [], + "getBuildingNumber": null, + "getCountry": "NL", + "getCountrySubDivision": null, + "getDepartment": null, + "getPostCode": null, + "getStreetName": null, + "getSubDepartment": null, + "getTownName": null + }, + "getName": "Company Name" + } + } + ], + "getRelatedParty": "__RECURSIVITY__", + "getRemittanceInformation": { + "__CLASS__": "Genkgo\\Camt\\DTO\\RemittanceInformation", + "getCreditorReferenceInformation": null, + "getMessage": "Transaction Description", + "getStructuredBlock": null, + "getStructuredBlocks": [], + "getUnstructuredBlock": { + "__CLASS__": "Genkgo\\Camt\\DTO\\UnstructuredRemittanceInformation", + "getMessage": "Transaction Description" + }, + "getUnstructuredBlocks": [ + "__RECURSIVITY__" + ] + }, + "getReturnInformation": null + }, + "getTransactionDetails": [ + "__RECURSIVITY__" + ], + "getValueDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-02T00:00:00+00:00" + } + } + ], + "getGroupHeader": { + "__CLASS__": "Genkgo\\Camt\\DTO\\GroupHeader", + "getAdditionalInformation": null, + "getCreatedOn": { + "__CLASS__": "DateTimeImmutable", + "0": "2015-01-25T11:22:43+00:00" + }, + "getMessageId": "CAMT05300000001", + "getMessageRecipient": null, + "getPagination": null + }, + "getRecords": [ + "__RECURSIVITY__" + ] +} diff --git a/test/data/camt053.v2.all-balance-types.xml b/test/data/camt053.v2.all-balance-types.xml new file mode 100644 index 0000000..79e9269 --- /dev/null +++ b/test/data/camt053.v2.all-balance-types.xml @@ -0,0 +1,200 @@ + + + + + CAMT05300000001 + 2015-01-25T12:22:43+01:00 + + + CAMT0532015012200001 + 315 + 2015-01-22T00:00:00+01:00 + + + + CH2801234000123456789 + + + + FINPETROL + + + + AAAA BANKEN + + SE + + + + + + + + OPBD + + + 1.01 + CRDT +
+
2015-01-21
+ +
+ + + + PRCD + + + 2.02 + CRDT +
+
2015-01-21
+ +
+ + + + OPAV + + + 3.03 + CRDT +
+
2015-01-22
+ +
+ + + + CLBD + + + 4.04 + CRDT +
+
2015-01-22
+ +
+ + + + CLAV + + + 5.05 + CRDT +
+
2015-01-23
+ +
+ + + + FWAV + + + 6.06 + CRDT +
+
2015-01-26
+ +
+ + + + INFO + + + 7.07 + CRDT +
+
2015-01-27
+ +
+ + + + ITAV + + + 8.08 + CRDT +
+
2015-01-28
+ +
+ + + + ITBD + + + 9.09 + CRDT +
+
2015-01-21
+ +
+ + + + XPCD + + + 10.10 + CRDT +
+
2015-01-21
+ +
+ + 8.850 + CRDT + false + BOOK + +
2014-12-31
+
+ +
2015-01-02
+
+ + + 544 + + + + + + 000000001 + + + + 544 + + + + + Company Name + + NL + + + + + NL56AGDH9619008421 + + + + + Transaction Description + + + +
+ Additional Information +
+
+
\ No newline at end of file From d7eeac18e14013e3c97622e6b9cce2f3991c97d3 Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Mon, 5 Aug 2024 15:55:10 +0200 Subject: [PATCH 3/6] test: Name data sets from data provider --- test/Unit/RegressionTest.php | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/Unit/RegressionTest.php b/test/Unit/RegressionTest.php index a5d335a..259fe9d 100644 --- a/test/Unit/RegressionTest.php +++ b/test/Unit/RegressionTest.php @@ -58,24 +58,24 @@ private function assertFile(string $file, string $actualContent): void public static function providerRegression(): iterable { - yield ['test/data/camt052.v1.xml']; - yield ['test/data/camt052.v2.other-account.xml']; - yield ['test/data/camt052.v2.xml']; - yield ['test/data/camt052.v4.xml']; - yield ['test/data/camt052.v6.xml']; - yield ['test/data/camt052.v8.xml']; - yield ['test/data/camt053.v2.five.decimals.xml']; - yield ['test/data/camt053.v2.minimal.ultimate.xml']; - yield ['test/data/camt053.v2.minimal.xml']; - yield ['test/data/camt053.v2.multi.statement.xml']; - yield ['test/data/camt053.v2.all-balance-types.xml']; - yield ['test/data/camt053.v3.xml']; - yield ['test/data/camt053.v4.xml']; - yield ['test/data/camt053.v8.xml']; - yield ['test/data/camt054.v2.xml']; - yield ['test/data/camt054.v4.xml']; - yield ['test/data/camt054.v8-with-UETR.xml']; - yield ['test/data/camt054.v8-with-financial-institution.xml']; - yield ['test/data/camt054.v8.xml']; + yield 'test/data/camt052.v1.xml' => ['test/data/camt052.v1.xml']; + yield 'test/data/camt052.v2.other-account.xml' => ['test/data/camt052.v2.other-account.xml']; + yield 'test/data/camt052.v2.xml' => ['test/data/camt052.v2.xml']; + yield 'test/data/camt052.v4.xml' => ['test/data/camt052.v4.xml']; + yield 'test/data/camt052.v6.xml' => ['test/data/camt052.v6.xml']; + yield 'test/data/camt052.v8.xml' => ['test/data/camt052.v8.xml']; + yield 'test/data/camt053.v2.five.decimals.xml' => ['test/data/camt053.v2.five.decimals.xml']; + yield 'test/data/camt053.v2.minimal.ultimate.xml'=> ['test/data/camt053.v2.minimal.ultimate.xml']; + yield 'test/data/camt053.v2.minimal.xml' => ['test/data/camt053.v2.minimal.xml']; + yield 'test/data/camt053.v2.multi.statement.xml' => ['test/data/camt053.v2.multi.statement.xml']; + yield 'test/data/camt053.v2.all-balance-types.xml' => ['test/data/camt053.v2.all-balance-types.xml']; + yield 'test/data/camt053.v3.xml' => ['test/data/camt053.v3.xml']; + yield 'test/data/camt053.v4.xml' => ['test/data/camt053.v4.xml']; + yield 'test/data/camt053.v8.xml' => ['test/data/camt053.v8.xml']; + yield 'test/data/camt054.v2.xml' => ['test/data/camt054.v2.xml']; + yield 'test/data/camt054.v4.xml' => ['test/data/camt054.v4.xml']; + yield 'test/data/camt054.v8-with-UETR.xml' => ['test/data/camt054.v8-with-UETR.xml']; + yield 'test/data/camt054.v8-with-financial-institution.xml' => ['test/data/camt054.v8-with-financial-institution.xml']; + yield 'test/data/camt054.v8.xml' => ['test/data/camt054.v8.xml']; } } From 736fade1c8adf5d3b96e73e7ca66dd13bf460a04 Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Mon, 5 Aug 2024 16:04:10 +0200 Subject: [PATCH 4/6] test: Correct regression from other test --- test/data/camt052.v4.json | 19 ++++++++++++++++++- test/data/camt052.v6.json | 19 ++++++++++++++++++- test/data/camt052.v6.xml | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/test/data/camt052.v4.json b/test/data/camt052.v4.json index 71a7b92..eb08709 100644 --- a/test/data/camt052.v4.json +++ b/test/data/camt052.v4.json @@ -49,7 +49,24 @@ "getIdentification": "CH2801234000123456789" }, "getAdditionalInformation": "Additional Information", - "getBalances": [], + "getBalances": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "1002215", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "CHF" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2016-06-14T00:00:00+00:00" + }, + "getType": "interim" + } + ], "getCopyDuplicateIndicator": "CODU", "getCreatedOn": { "__CLASS__": "DateTimeImmutable", diff --git a/test/data/camt052.v6.json b/test/data/camt052.v6.json index 0879fe5..f80ef45 100644 --- a/test/data/camt052.v6.json +++ b/test/data/camt052.v6.json @@ -49,7 +49,24 @@ "getIdentification": "CH2801234000123456789" }, "getAdditionalInformation": "Additional Information", - "getBalances": [], + "getBalances": [ + { + "__CLASS__": "Genkgo\\Camt\\DTO\\Balance", + "getAmount": { + "__CLASS__": "Money\\Money", + "getAmount": "1002215", + "getCurrency": { + "__CLASS__": "Money\\Currency", + "getCode": "CHF" + } + }, + "getDate": { + "__CLASS__": "DateTimeImmutable", + "0": "2020-04-04T00:00:00+00:00" + }, + "getType": "interim" + } + ], "getCopyDuplicateIndicator": "CODU", "getCreatedOn": { "__CLASS__": "DateTimeImmutable", diff --git a/test/data/camt052.v6.xml b/test/data/camt052.v6.xml index fec4c9f..e133b92 100644 --- a/test/data/camt052.v6.xml +++ b/test/data/camt052.v6.xml @@ -64,7 +64,7 @@ 10022.15 CRDT
- 2020-04-04T13:45:34.414+02:00 +
2020-04-04
From 5ca870652241cab7233ac6001d7148e9ae03db4f Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Tue, 6 Aug 2024 10:07:01 +0200 Subject: [PATCH 5/6] Code style --- test/Unit/RegressionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Unit/RegressionTest.php b/test/Unit/RegressionTest.php index 259fe9d..6629ca4 100644 --- a/test/Unit/RegressionTest.php +++ b/test/Unit/RegressionTest.php @@ -65,7 +65,7 @@ public static function providerRegression(): iterable yield 'test/data/camt052.v6.xml' => ['test/data/camt052.v6.xml']; yield 'test/data/camt052.v8.xml' => ['test/data/camt052.v8.xml']; yield 'test/data/camt053.v2.five.decimals.xml' => ['test/data/camt053.v2.five.decimals.xml']; - yield 'test/data/camt053.v2.minimal.ultimate.xml'=> ['test/data/camt053.v2.minimal.ultimate.xml']; + yield 'test/data/camt053.v2.minimal.ultimate.xml' => ['test/data/camt053.v2.minimal.ultimate.xml']; yield 'test/data/camt053.v2.minimal.xml' => ['test/data/camt053.v2.minimal.xml']; yield 'test/data/camt053.v2.multi.statement.xml' => ['test/data/camt053.v2.multi.statement.xml']; yield 'test/data/camt053.v2.all-balance-types.xml' => ['test/data/camt053.v2.all-balance-types.xml']; From e634866f4b945829571ccb924acc1dbf62eae9c3 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Tue, 6 Aug 2024 10:19:54 +0200 Subject: [PATCH 6/6] Automate the list of files for regression test --- test/Unit/RegressionTest.php | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/test/Unit/RegressionTest.php b/test/Unit/RegressionTest.php index 6629ca4..bbc577e 100644 --- a/test/Unit/RegressionTest.php +++ b/test/Unit/RegressionTest.php @@ -27,14 +27,13 @@ protected function tearDown(): void /** * @dataProvider providerRegression */ - public function testRegression(string $file): void + public function testRegression(string $file, string $expectedFile): void { $reader = new Reader(Config::getDefault()); $message = $reader->readFile($file); $dumper = new Dumper(); $actual = $dumper->dump($message); - $expectedFile = str_replace('.xml', '.json', $file); $this->assertFile($expectedFile, $actual); } @@ -58,24 +57,11 @@ private function assertFile(string $file, string $actualContent): void public static function providerRegression(): iterable { - yield 'test/data/camt052.v1.xml' => ['test/data/camt052.v1.xml']; - yield 'test/data/camt052.v2.other-account.xml' => ['test/data/camt052.v2.other-account.xml']; - yield 'test/data/camt052.v2.xml' => ['test/data/camt052.v2.xml']; - yield 'test/data/camt052.v4.xml' => ['test/data/camt052.v4.xml']; - yield 'test/data/camt052.v6.xml' => ['test/data/camt052.v6.xml']; - yield 'test/data/camt052.v8.xml' => ['test/data/camt052.v8.xml']; - yield 'test/data/camt053.v2.five.decimals.xml' => ['test/data/camt053.v2.five.decimals.xml']; - yield 'test/data/camt053.v2.minimal.ultimate.xml' => ['test/data/camt053.v2.minimal.ultimate.xml']; - yield 'test/data/camt053.v2.minimal.xml' => ['test/data/camt053.v2.minimal.xml']; - yield 'test/data/camt053.v2.multi.statement.xml' => ['test/data/camt053.v2.multi.statement.xml']; - yield 'test/data/camt053.v2.all-balance-types.xml' => ['test/data/camt053.v2.all-balance-types.xml']; - yield 'test/data/camt053.v3.xml' => ['test/data/camt053.v3.xml']; - yield 'test/data/camt053.v4.xml' => ['test/data/camt053.v4.xml']; - yield 'test/data/camt053.v8.xml' => ['test/data/camt053.v8.xml']; - yield 'test/data/camt054.v2.xml' => ['test/data/camt054.v2.xml']; - yield 'test/data/camt054.v4.xml' => ['test/data/camt054.v4.xml']; - yield 'test/data/camt054.v8-with-UETR.xml' => ['test/data/camt054.v8-with-UETR.xml']; - yield 'test/data/camt054.v8-with-financial-institution.xml' => ['test/data/camt054.v8-with-financial-institution.xml']; - yield 'test/data/camt054.v8.xml' => ['test/data/camt054.v8.xml']; + foreach ((glob('test/data/*.xml') ?: []) as $file) { + $expectedFile = str_replace('.xml', '.json', $file); + if (is_file($expectedFile)) { + yield $file => [$file, $expectedFile]; + } + } } }