From e4bfc04df3a3e6db1e9475353821f8cfae8ef062 Mon Sep 17 00:00:00 2001 From: Ondra Date: Wed, 25 Oct 2023 10:43:10 +0200 Subject: [PATCH] remove mapping in raw mode --- src/Configuration/ConfigDefinition.php | 6 +--- tests/phpunit/ConfigTest.php | 44 ++++++++++++++++++-------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Configuration/ConfigDefinition.php b/src/Configuration/ConfigDefinition.php index c19dd4c..2f90876 100644 --- a/src/Configuration/ConfigDefinition.php +++ b/src/Configuration/ConfigDefinition.php @@ -95,11 +95,7 @@ protected function getParametersDefinition(): ArrayNodeDefinition // Validate mode switch ($v['mode']) { case self::MODE_RAW: - if (isset($v['mapping'])) { - throw new InvalidConfigurationException( - 'Invalid configuration, "mapping" is configured, but mode is set to "raw".' - ); - } + unset($v['mapping']); break; case self::MODE_MAPPING: diff --git a/tests/phpunit/ConfigTest.php b/tests/phpunit/ConfigTest.php index 4fbc7a4..6285c3f 100644 --- a/tests/phpunit/ConfigTest.php +++ b/tests/phpunit/ConfigTest.php @@ -192,6 +192,37 @@ public function getValidConfigs(): iterable 'incrementalFetchingKey' => null, ], ]; + + yield 'raw-mapping' => [ + [ + 'db' => $this->getDbNode(), + 'id' => 123, + 'name' => 'row123', + 'containerId' => 'myContainer', + 'output' => 'output-csv', + 'mode' => 'raw', + 'mapping' => ['abc' => 'def'], + ], + [ + 'endpoint' => 'https://abc.example.com', + 'key' => '12345', + 'databaseId' => 'myDatabase', + 'containerId' => 'myContainer', + 'output' => 'output-csv', + 'configRowId' => 123, + 'configRowName' => 'row123', + 'maxTries' => 5, + 'select' => null, + 'from' => null, + 'sort' => null, + 'limit' => null, + 'query' => null, + 'mode' => 'raw', + 'mapping' => null, + 'isIncremental' => false, + 'incrementalFetchingKey' => null, + ], + ]; } public function getInvalidConfigs(): iterable @@ -213,19 +244,6 @@ public function getInvalidConfigs(): iterable ], ]; - yield 'unexpected-mapping' => [ - 'Invalid configuration, "mapping" is configured, but mode is set to "raw".', - [ - 'db' => $this->getDbNode(), - 'id' => 123, - 'name' => 'row123', - 'containerId' => 'myContainer', - 'output' => 'output-csv', - 'mode' => 'raw', - 'mapping' => ['abc' => 'def'], - ], - ]; - yield 'query-and-select' => [ 'Invalid configuration, "query" cannot be configured together with "select".', [