From 6fa0c6759d7314336399df29dceda728b1a0864b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Tue, 7 Dec 2021 18:43:18 +0100 Subject: [PATCH 1/2] Enhancement: Assert that default config has all supported message formats --- test/Unit/ConfigTest.php | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/Unit/ConfigTest.php b/test/Unit/ConfigTest.php index fbacc5c..7345eca 100644 --- a/test/Unit/ConfigTest.php +++ b/test/Unit/ConfigTest.php @@ -4,7 +4,11 @@ namespace Genkgo\TestCamt\Unit; +use Genkgo\Camt\Camt052; +use Genkgo\Camt\Camt053; +use Genkgo\Camt\Camt054; use Genkgo\Camt\Config; +use Genkgo\Camt\MessageFormatInterface; use PHPUnit\Framework\TestCase; /** @@ -12,6 +16,65 @@ */ class ConfigTest extends TestCase { + public function testDefaultConfigHasMessageFormats(): void + { + $config = Config::getDefault(); + + $messageFormats = $config->getMessageFormats(); + + $expectedMessageFormats = [ + Camt052\MessageFormat\V01::class, + Camt052\MessageFormat\V02::class, + Camt052\MessageFormat\V04::class, + Camt052\MessageFormat\V06::class, + Camt053\MessageFormat\V02::class, + Camt053\MessageFormat\V03::class, + Camt053\MessageFormat\V04::class, + Camt054\MessageFormat\V02::class, + Camt054\MessageFormat\V04::class, + ]; + + $actualMessageFormats = array_map(static function (MessageFormatInterface $messageFormat): string { + return get_class($messageFormat); + }, $messageFormats); + + $additionalMessageFormats = array_diff( + $actualMessageFormats, + $expectedMessageFormats + ); + + self::assertEmpty($additionalMessageFormats, sprintf( + << Date: Tue, 7 Dec 2021 18:45:36 +0100 Subject: [PATCH 2/2] Fix: Register Camt052\MessageFormat\V02 --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index fadb3c2..2dc643b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -47,6 +47,7 @@ public static function getDefault(): self { $config = new self(); $config->addMessageFormat(new Camt052\MessageFormat\V01()); + $config->addMessageFormat(new Camt052\MessageFormat\V02()); $config->addMessageFormat(new Camt052\MessageFormat\V04()); $config->addMessageFormat(new Camt052\MessageFormat\V06()); $config->addMessageFormat(new Camt053\MessageFormat\V02());