diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nPackCommandTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nPackCommandTest.php index 9ad14d27f6220bb58d4919f4bea45991ccf0c248..0185b06a5376b5b20884e28a241ca9d5a76854f4 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nPackCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nPackCommandTest.php @@ -67,6 +67,23 @@ class I18nPackCommandTest extends \PHPUnit_Framework_TestCase ); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Possible values for 'mode' option are 'replace' and 'merge' + */ + public function testExecuteInvalidMode() + { + $this->tester->execute( + [ + 'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv', + 'pack' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/pack', + 'locale' => 'de_DE', + '--allow-duplicates' => true, + '--mode' => 'invalid' + ] + ); + } + /** * Removes directories recursively * diff --git a/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php b/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php index 0d5a74449eac8ef65f07eea9ce42e99c8b25c4f0..b75eff98e7e88fa5617d0ed2edba34f4427dd174 100644 --- a/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php +++ b/setup/src/Magento/Setup/Console/Command/I18nPackCommand.php @@ -24,11 +24,19 @@ class I18nPackCommand extends Command const INPUT_KEY_PACK = 'pack'; const INPUT_KEY_LOCALE = 'locale'; const INPUT_KEY_MODE = 'mode'; - const SHORTCUT_KEY_MODE = 'm'; const INPUT_KEY_ALLOW_DUPLICATES = 'allow-duplicates'; - const SHORTCUT_KEY_ALLOW_DUPLICATES = 'd'; /**#@-*/ + /** + * 'replace' mode value + */ + const MODE_REPLACE = 'replace'; + + /** + * 'merge' mode value + */ + const MODE_MERGE = 'merge'; + /** * {@inheritdoc} */ @@ -54,16 +62,18 @@ class I18nPackCommand extends Command ), new InputOption( self::INPUT_KEY_MODE, - self::SHORTCUT_KEY_MODE, + 'm', InputOption::VALUE_REQUIRED, 'Save mode for dictionary' . PHP_EOL . '- "replace" - replace language pack by new one' . PHP_EOL . - '- "merge" - merge language packages, by default "replace"' + '- "merge" - merge language packages, by default "replace"', + self::MODE_REPLACE ), new InputOption( self::INPUT_KEY_ALLOW_DUPLICATES, - self::SHORTCUT_KEY_ALLOW_DUPLICATES, + 'd', InputOption::VALUE_NONE, - 'Flag indicates if allowed to save duplicates of translate, false by default' + 'Use the --allow-duplicates parameter to allow to save duplicates of translate.' . + ' Omit the parameter otherwise.' ), ]); } @@ -74,6 +84,10 @@ class I18nPackCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { $generator = ServiceLocator::getPackGenerator(); + $mode = $input->getOption(self::INPUT_KEY_MODE); + if ($mode !== self::MODE_MERGE && $mode !== self::MODE_REPLACE) { + throw new \InvalidArgumentException("Possible values for 'mode' option are 'replace' and 'merge'"); + } $locale = $input->getArgument(self::INPUT_KEY_LOCALE); $generator->generate( $input->getArgument(self::INPUT_KEY_SOURCE),