From d9c2300489e6ad35d0255f0345356fce2ad3b273 Mon Sep 17 00:00:00 2001 From: Alexander Nitsche <typo3@alexandernitsche.com> Date: Sun, 15 Aug 2021 15:50:48 +0200 Subject: [PATCH] [TASK] Deprecate lowerCamelCase options of EXT:impexp commands Adapting the "impexp:export" and "impexp:import" commands to the TYPO3 Core and replacing all lowerCamelCase options with lowercase options. The lowerCamelCase options will be removed in TYPO3 v12. Perform explicit instead of implicit command argument testing to tackle the increased complexity introduced by the handling of deprecated and future-proof arguments. Align naming of command options "pid" and "pageId" Align some command option descriptions. Resolves: #94902 Releases: master Change-Id: Ibd30a89e6ba81f27753979da944bde4d104aeb95 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70599 Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Alexander Nitsche <typo3@alexandernitsche.com> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Alexander Nitsche <typo3@alexandernitsche.com> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- ...werCamelCaseOptionsOfExtImpExpCommands.rst | 50 ++++++++ .../impexp/Classes/Command/ExportCommand.php | 101 +++++++++++++-- .../impexp/Classes/Command/ImportCommand.php | 116 +++++++++++++++--- .../Functional/Command/ExportCommandTest.php | 42 ++++--- .../Functional/Command/ImportCommandTest.php | 40 +++--- 5 files changed, 286 insertions(+), 63 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-94902-LowerCamelCaseOptionsOfExtImpExpCommands.rst diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94902-LowerCamelCaseOptionsOfExtImpExpCommands.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94902-LowerCamelCaseOptionsOfExtImpExpCommands.rst new file mode 100644 index 000000000000..ced24fbbf54a --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-94902-LowerCamelCaseOptionsOfExtImpExpCommands.rst @@ -0,0 +1,50 @@ +.. include:: ../../Includes.txt + +============================================================================= +Deprecation: #94902 - Deprecate lowerCamelCase options of EXT:impexp commands +============================================================================= + +See :issue:`94902` + +Description +=========== + +The CLI commands :shell:`impexp:export` and :shell:`impexp:import` offered +lowerCamelCased options, while the other TYPO3 Core commands offer lowercase +options only. The lowercase option aliases were introduced in both commands and +the lowerCamelCased options were marked as deprecated and will be removed in +TYPO3 v12. + + +Impact +====== + +If the CLI commands :shell:`impexp:export` or :shell:`impexp:import` are +executed with lowerCamelCased options, a PHP :php:`E_USER_DEPRECATED` error is +raised. + + +Affected Installations +====================== + +Any TYPO3 installation using lowerCamelCased options with commands +:shell:`impexp:export` or :shell:`impexp:import`. + + +Migration +========= + +Switch to the lower-cased option aliases: + +1. :shell:`impexp:export --includeRelated` => :shell:`impexp:export --include-related` +2. :shell:`impexp:export --includeStatic` => :shell:`impexp:export --include-static` +3. :shell:`impexp:export --excludeDisabledRecords` => :shell:`impexp:export --exclude-disabled-records` +4. :shell:`impexp:export --excludeHtmlCss` => :shell:`impexp:export --exclude-html-css` +5. :shell:`impexp:export --saveFilesOutsideExportFile` => :shell:`impexp:export --save-files-outside-export-file` +6. :shell:`impexp:import --updateRecords` => :shell:`impexp:import --update-records` +7. :shell:`impexp:import --ignorePid` => :shell:`impexp:import --ignore-pid` +8. :shell:`impexp:import --forceUid` => :shell:`impexp:import --force-uid` +9. :shell:`impexp:import --importMode` => :shell:`impexp:import --import-mode` +10. :shell:`impexp:import --enableLog` => :shell:`impexp:import --enable-log` + +.. index:: CLI, NotScanned, ext:impexp diff --git a/typo3/sysext/impexp/Classes/Command/ExportCommand.php b/typo3/sysext/impexp/Classes/Command/ExportCommand.php index e1504c64ee6b..12ee38291e36 100644 --- a/typo3/sysext/impexp/Classes/Command/ExportCommand.php +++ b/typo3/sysext/impexp/Classes/Command/ExportCommand.php @@ -49,7 +49,7 @@ class ExportCommand extends Command ->addArgument( 'filename', InputArgument::OPTIONAL, - 'The filename to export to (without file extension)' + 'The filename to export to (without file extension).' ) ->addOption( 'type', @@ -102,13 +102,13 @@ class ExportCommand extends Command 'Include the records of this table and this page. Pattern is "{table}:{pid}". Examples: "sys_language:0", etc.' ) ->addOption( - 'includeRelated', + 'include-related', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Include record relations to this table, including the related record. Examples: "_ALL", "sys_category", etc.' ) ->addOption( - 'includeStatic', + 'include-static', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Include record relations to this table, excluding the related record. Examples: "_ALL", "sys_language", etc.' @@ -120,13 +120,13 @@ class ExportCommand extends Command 'Exclude this specific record. Pattern is "{table}:{record}". Examples: "fe_users:3", etc.' ) ->addOption( - 'excludeDisabledRecords', + 'exclude-disabled-records', null, InputOption::VALUE_NONE, 'Exclude records which are handled as disabled by their TCA configuration, e.g. by fields "disabled", "starttime" or "endtime".' ) ->addOption( - 'excludeHtmlCss', + 'exclude-html-css', null, InputOption::VALUE_NONE, 'Exclude referenced HTML and CSS files.' @@ -156,11 +156,42 @@ class ExportCommand extends Command 'This TYPO3 extension is required for the exported records. Examples: "news", "powermail", etc.' ) ->addOption( - 'saveFilesOutsideExportFile', + 'save-files-outside-export-file', null, InputOption::VALUE_NONE, 'Save files into separate folder instead of including them into the common export file. Folder name pattern is "{filename}.files".' ) + // @deprecated since v11, will be removed in v12. Drop all options below and look for other fallbacks in the class. + ->addOption( + 'includeRelated', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'Deprecated. Use --include-related instead.' + ) + ->addOption( + 'includeStatic', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'Deprecated. Use --include-static instead.' + ) + ->addOption( + 'excludeDisabledRecords', + null, + InputOption::VALUE_NONE, + 'Deprecated. Use --exclude-disabled-records instead.' + ) + ->addOption( + 'excludeHtmlCss', + null, + InputOption::VALUE_NONE, + 'Deprecated. Use --exclude-html-css instead.' + ) + ->addOption( + 'saveFilesOutsideExportFile', + null, + InputOption::VALUE_NONE, + 'Deprecated. Use --save-files-outside-export-file instead.' + ) ; } @@ -173,6 +204,20 @@ class ExportCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { + // @deprecated since v11, will be removed in v12. lowerCameCased options. Also look for other fallbacks in the class. + $deprecatedOptions = [ + '--includeRelated' => '--include-related', + '--includeStatic' => '--include-static', + '--excludeDisabledRecords' => '--exclude-disabled-records', + '--excludeHtmlCss' => '--exclude-html-css', + '--saveFilesOutsideExportFile' => '--save-files-outside-export-file', + ]; + foreach ($deprecatedOptions as $deprecatedName => $actualName) { + if ($input->hasParameterOption($deprecatedName, true)) { + $this->triggerCommandOptionDeprecation($deprecatedName, $actualName); + } + } + // Ensure the _cli_ user is authenticated Bootstrap::initializeBackendAuthentication(); @@ -186,16 +231,35 @@ class ExportCommand extends Command $this->export->setTables($input->getOption('table')); $this->export->setRecord($input->getOption('record')); $this->export->setList($input->getOption('list')); - $this->export->setRelOnlyTables($input->getOption('includeRelated')); - $this->export->setRelStaticTables($input->getOption('includeStatic')); + $this->export->setRelOnlyTables( + array_merge( + $input->getOption('includeRelated'), + $input->getOption('include-related') + ) + ); + $this->export->setRelStaticTables( + array_merge( + $input->getOption('includeStatic'), + $input->getOption('include-static') + ) + ); $this->export->setExcludeMap($input->getOption('exclude')); - $this->export->setExcludeDisabledRecords($input->getOption('excludeDisabledRecords')); - $this->export->setIncludeExtFileResources(!$input->getOption('excludeHtmlCss')); + $this->export->setExcludeDisabledRecords( + $input->getOption('excludeDisabledRecords') || + $input->getOption('exclude-disabled-records') + ); + $this->export->setIncludeExtFileResources(!( + $input->getOption('excludeHtmlCss') || + $input->getOption('exclude-html-css') + )); $this->export->setTitle((string)$input->getOption('title')); $this->export->setDescription((string)$input->getOption('description')); $this->export->setNotes((string)$input->getOption('notes')); $this->export->setExtensionDependencies($input->getOption('dependency')); - $this->export->setSaveFilesOutsideExportFile($input->getOption('saveFilesOutsideExportFile')); + $this->export->setSaveFilesOutsideExportFile( + $input->getOption('saveFilesOutsideExportFile') || + $input->getOption('save-files-outside-export-file') + ); $this->export->process(); $saveFile = $this->export->saveToFile(); $io->success('Exporting to ' . $saveFile->getPublicUrl() . ' succeeded.'); @@ -209,4 +273,19 @@ class ExportCommand extends Command return 1; } } + + /** + * @deprecated since v11, will be removed in v12. Drop all options below and look for other fallbacks in the class. + */ + protected function triggerCommandOptionDeprecation(string $deprecatedName, string $actualName): void + { + trigger_error( + sprintf( + 'Command option "impexp:export %s" is deprecated and will be removed in v12. Use "%s" instead.', + $deprecatedName, + $actualName + ), + E_USER_DEPRECATED + ); + } } diff --git a/typo3/sysext/impexp/Classes/Command/ImportCommand.php b/typo3/sysext/impexp/Classes/Command/ImportCommand.php index 3f7a07266091..36e3d41213a7 100644 --- a/typo3/sysext/impexp/Classes/Command/ImportCommand.php +++ b/typo3/sysext/impexp/Classes/Command/ImportCommand.php @@ -49,34 +49,34 @@ class ImportCommand extends Command ->addArgument( 'file', InputArgument::REQUIRED, - 'The path and filename to import (.t3d or .xml)' + 'The file path to import from (.t3d or .xml).' ) ->addArgument( - 'pageId', + 'pid', InputArgument::OPTIONAL, - 'The page ID to start from.', + 'The page to import to.', 0 ) ->addOption( - 'updateRecords', + 'update-records', null, InputOption::VALUE_NONE, - 'If set, existing records with the same UID will be updated instead of inserted' + 'If set, existing records with the same UID will be updated instead of inserted.' ) ->addOption( - 'ignorePid', + 'ignore-pid', null, InputOption::VALUE_NONE, - 'If set, page IDs of updated records are not corrected (only works in conjunction with the updateRecords option)' + 'If set, page IDs of updated records are not corrected (only works in conjunction with --update-records).' ) ->addOption( - 'forceUid', + 'force-uid', null, InputOption::VALUE_NONE, 'If set, UIDs from file will be forced.' ) ->addOption( - 'importMode', + 'import-mode', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, sprintf( @@ -92,12 +92,44 @@ class ImportCommand extends Command Import::IMPORT_MODE_RESPECT_PID ) ) + ->addOption( + 'enable-log', + null, + InputOption::VALUE_NONE, + 'If set, all database actions are logged.' + ) + // @deprecated since v11, will be removed in v12. Drop all options below and look for other fallbacks in the class. + ->addOption( + 'updateRecords', + null, + InputOption::VALUE_NONE, + 'Deprecated. Use --update-records instead.' + ) + ->addOption( + 'ignorePid', + null, + InputOption::VALUE_NONE, + 'Deprecated. Use --ignore-pid instead.' + ) + ->addOption( + 'forceUid', + null, + InputOption::VALUE_NONE, + 'Deprecated. Use --force-uid instead.' + ) + ->addOption( + 'importMode', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'Deprecated. Use --import-mode instead.' + ) ->addOption( 'enableLog', null, InputOption::VALUE_NONE, - 'If set, all database actions are logged' - ); + 'Deprecated. Use --enable-log instead.' + ) + ; } /** @@ -109,26 +141,57 @@ class ImportCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { + // @deprecated since v11, will be removed in v12. lowerCameCased options. Also look for other fallbacks in the class. + $deprecatedOptions = [ + '--updateRecords' => '--update-records', + '--ignorePid' => '--ignore-pid', + '--forceUid' => '--force-uid', + '--importMode' => '--import-mode', + '--enableLog' => '--enable-log', + ]; + foreach ($deprecatedOptions as $deprecatedName => $actualName) { + if ($input->hasParameterOption($deprecatedName, true)) { + $this->triggerCommandOptionDeprecation($deprecatedName, $actualName); + } + } + // Ensure the _cli_ user is authenticated Bootstrap::initializeBackendAuthentication(); $io = new SymfonyStyle($input, $output); try { - $this->import->setPid((int)$input->getArgument('pageId')); - $this->import->setUpdate((bool)$input->getOption('updateRecords')); - $this->import->setGlobalIgnorePid((bool)$input->getOption('ignorePid')); - $this->import->setForceAllUids((bool)$input->getOption('forceUid')); - $this->import->setImportMode($this->parseAssociativeArray($input, 'importMode', '=')); - $this->import->setEnableLogging((bool)$input->getOption('enableLog')); + $this->import->setPid((int)$input->getArgument('pid')); + $this->import->setUpdate( + $input->getOption('updateRecords') || + $input->getOption('update-records') + ); + $this->import->setGlobalIgnorePid( + $input->getOption('ignorePid') || + $input->getOption('ignore-pid') + ); + $this->import->setForceAllUids( + $input->getOption('forceUid') || + $input->getOption('force-uid') + ); + $this->import->setEnableLogging( + $input->getOption('enableLog') || + $input->getOption('enable-log') + ); + $this->import->setImportMode( + array_merge( + $this->parseAssociativeArray($input, 'importMode', '='), + $this->parseAssociativeArray($input, 'import-mode', '='), + ) + ); $this->import->loadFile((string)$input->getArgument('file'), true); $this->import->checkImportPrerequisites(); $this->import->importData(); - $io->success('Importing ' . $input->getArgument('file') . ' to page ' . $input->getArgument('pageId') . ' succeeded.'); + $io->success('Importing ' . $input->getArgument('file') . ' to page ' . $input->getArgument('pid') . ' succeeded.'); return 0; } catch (\Exception $e) { // Since impexp triggers core and DataHandler with potential hooks, and exception could come from "everywhere". - $io->error('Importing ' . $input->getArgument('file') . ' to page ' . $input->getArgument('pageId') . ' failed.'); + $io->error('Importing ' . $input->getArgument('file') . ' to page ' . $input->getArgument('pid') . ' failed.'); if ($io->isVerbose()) { $io->writeln($e->getMessage()); $io->writeln($this->import->getErrorLog()); @@ -137,6 +200,21 @@ class ImportCommand extends Command } } + /** + * @deprecated since v11, will be removed in v12. Drop all options below and look for other fallbacks in the class. + */ + protected function triggerCommandOptionDeprecation(string $deprecatedName, string $actualName): void + { + trigger_error( + sprintf( + 'Command option "impexp:import %s" is deprecated and will be removed in v12. Use "%s" instead.', + $deprecatedName, + $actualName + ), + E_USER_DEPRECATED + ); + } + /** * Parse a basic commandline option array into an associative array by splitting each entry into a key part and * a value part using a specific separator. diff --git a/typo3/sysext/impexp/Tests/Functional/Command/ExportCommandTest.php b/typo3/sysext/impexp/Tests/Functional/Command/ExportCommandTest.php index 788f51f8af66..f81fe167c596 100644 --- a/typo3/sysext/impexp/Tests/Functional/Command/ExportCommandTest.php +++ b/typo3/sysext/impexp/Tests/Functional/Command/ExportCommandTest.php @@ -72,15 +72,21 @@ class ExportCommandTest extends AbstractImportExportTestCase '--table' => ['tt_content'], '--record' => ['sys_category:6'], '--list' => ['sys_category:123'], - '--includeRelated' => ['be_users'], + '--include-related' => ['be_users'], + // @deprecated since v11, will be removed in v12. Drop the lowerCamelCase options. + '--includeRelated' => ['be_groups'], + '--include-static' => ['sys_category'], '--includeStatic' => ['sys_language'], '--exclude' => ['be_users:3'], + '--exclude-disabled-records' => false, '--excludeDisabledRecords' => true, + '--exclude-html-css' => false, '--excludeHtmlCss' => true, '--title' => 'Export Command', '--description' => 'The export which considers all arguments passed on the command line.', '--notes' => 'This export is not for production use.', '--dependency' => ['bootstrap_package'], + '--save-files-outside-export-file' => false, '--saveFilesOutsideExportFile' => true ]; @@ -90,23 +96,23 @@ class ExportCommandTest extends AbstractImportExportTestCase 'setIncludeExtFileResources', 'setTitle', 'setDescription', 'setNotes', 'setExtensionDependencies', 'setSaveFilesOutsideExportFile' ]); - $exportMock->expects(self::once())->method('setExportFileName')->with(self::equalTo($input['filename'])); - $exportMock->expects(self::once())->method('setExportFileType')->with(self::equalTo($input['--type'])); - $exportMock->expects(self::once())->method('setPid')->with(self::equalTo($input['--pid'])); - $exportMock->expects(self::once())->method('setLevels')->with(self::equalTo($input['--levels'])); - $exportMock->expects(self::once())->method('setTables')->with(self::equalTo($input['--table'])); - $exportMock->expects(self::once())->method('setRecord')->with(self::equalTo($input['--record'])); - $exportMock->expects(self::once())->method('setList')->with(self::equalTo($input['--list'])); - $exportMock->expects(self::once())->method('setRelOnlyTables')->with(self::equalTo($input['--includeRelated'])); - $exportMock->expects(self::once())->method('setRelStaticTables')->with(self::equalTo($input['--includeStatic'])); - $exportMock->expects(self::once())->method('setExcludeMap')->with(self::equalTo($input['--exclude'])); - $exportMock->expects(self::once())->method('setExcludeDisabledRecords')->with(self::equalTo($input['--excludeDisabledRecords'])); - $exportMock->expects(self::once())->method('setIncludeExtFileResources')->with(self::equalTo(!$input['--excludeHtmlCss'])); - $exportMock->expects(self::once())->method('setTitle')->with(self::equalTo($input['--title'])); - $exportMock->expects(self::once())->method('setDescription')->with(self::equalTo($input['--description'])); - $exportMock->expects(self::once())->method('setNotes')->with(self::equalTo($input['--notes'])); - $exportMock->expects(self::once())->method('setExtensionDependencies')->with(self::equalTo($input['--dependency'])); - $exportMock->expects(self::once())->method('setSaveFilesOutsideExportFile')->with(self::equalTo($input['--saveFilesOutsideExportFile'])); + $exportMock->expects(self::once())->method('setExportFileName')->with(self::equalTo('empty_export')); + $exportMock->expects(self::once())->method('setExportFileType')->with(self::equalTo(Export::FILETYPE_T3D)); + $exportMock->expects(self::once())->method('setPid')->with(self::equalTo(123)); + $exportMock->expects(self::once())->method('setLevels')->with(self::equalTo(Export::LEVELS_RECORDS_ON_THIS_PAGE)); + $exportMock->expects(self::once())->method('setTables')->with(self::equalTo(['tt_content'])); + $exportMock->expects(self::once())->method('setRecord')->with(self::equalTo(['sys_category:6'])); + $exportMock->expects(self::once())->method('setList')->with(self::equalTo(['sys_category:123'])); + $exportMock->expects(self::once())->method('setRelOnlyTables')->with(self::equalTo(['be_groups', 'be_users'])); + $exportMock->expects(self::once())->method('setRelStaticTables')->with(self::equalTo(['sys_language', 'sys_category'])); + $exportMock->expects(self::once())->method('setExcludeMap')->with(self::equalTo(['be_users:3'])); + $exportMock->expects(self::once())->method('setExcludeDisabledRecords')->with(self::equalTo(true)); + $exportMock->expects(self::once())->method('setIncludeExtFileResources')->with(self::equalTo(false)); + $exportMock->expects(self::once())->method('setTitle')->with(self::equalTo('Export Command')); + $exportMock->expects(self::once())->method('setDescription')->with(self::equalTo('The export which considers all arguments passed on the command line.')); + $exportMock->expects(self::once())->method('setNotes')->with(self::equalTo('This export is not for production use.')); + $exportMock->expects(self::once())->method('setExtensionDependencies')->with(self::equalTo(['bootstrap_package'])); + $exportMock->expects(self::once())->method('setSaveFilesOutsideExportFile')->with(self::equalTo(true)); $tester = new CommandTester(new ExportCommand($exportMock)); $tester->execute($input); diff --git a/typo3/sysext/impexp/Tests/Functional/Command/ImportCommandTest.php b/typo3/sysext/impexp/Tests/Functional/Command/ImportCommandTest.php index 962dd5ce63d2..676bccd9ccc4 100644 --- a/typo3/sysext/impexp/Tests/Functional/Command/ImportCommandTest.php +++ b/typo3/sysext/impexp/Tests/Functional/Command/ImportCommandTest.php @@ -54,11 +54,20 @@ class ImportCommandTest extends AbstractImportExportTestCase { $input = [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/sys_language.xml', - 'pageId' => 3, + 'pid' => 3, + // @deprecated since v11, will be removed in v12. Drop the lowerCamelCase options. + '--update-records' => false, '--updateRecords' => true, + '--ignore-pid' => false, '--ignorePid' => true, + '--force-uid' => false, '--forceUid' => true, + '--enable-log' => false, '--enableLog' => true, + '--import-mode' => [ + sprintf('pages:789=%s', Import::IMPORT_MODE_FORCE_UID), + sprintf('tt_content:1=%s', Import::IMPORT_MODE_EXCLUDE) + ], '--importMode' => [ sprintf('pages:987=%s', Import::IMPORT_MODE_FORCE_UID), sprintf('tt_content:1=%s', Import::IMPORT_MODE_AS_NEW) @@ -70,16 +79,17 @@ class ImportCommandTest extends AbstractImportExportTestCase 'setImportMode' ]); - $importMock->expects(self::once())->method('setPid')->with(self::equalTo($input['pageId'])); - $importMock->expects(self::once())->method('setUpdate')->with(self::equalTo($input['--updateRecords'])); - $importMock->expects(self::once())->method('setGlobalIgnorePid')->with(self::equalTo($input['--ignorePid'])); - $importMock->expects(self::once())->method('setForceAllUids')->with(self::equalTo($input['--forceUid'])); - $importMock->expects(self::once())->method('setEnableLogging')->with(self::equalTo($input['--enableLog'])); - $importMock->expects(self::once())->method('loadFile')->with(self::equalTo($input['file'])); + $importMock->expects(self::once())->method('setPid')->with(self::equalTo(3)); + $importMock->expects(self::once())->method('setUpdate')->with(self::equalTo(true)); + $importMock->expects(self::once())->method('setGlobalIgnorePid')->with(self::equalTo(true)); + $importMock->expects(self::once())->method('setForceAllUids')->with(self::equalTo(true)); + $importMock->expects(self::once())->method('setEnableLogging')->with(self::equalTo(true)); $importMock->expects(self::once())->method('setImportMode')->with(self::equalTo([ 'pages:987' => Import::IMPORT_MODE_FORCE_UID, - 'tt_content:1' => Import::IMPORT_MODE_AS_NEW, + 'tt_content:1' => Import::IMPORT_MODE_EXCLUDE, + 'pages:789' => Import::IMPORT_MODE_FORCE_UID, ])); + $importMock->expects(self::once())->method('loadFile')->with(self::equalTo('EXT:impexp/Tests/Functional/Fixtures/XmlImports/sys_language.xml')); $tester = new CommandTester(new ImportCommand($importMock)); $tester->execute($input); @@ -91,44 +101,44 @@ class ImportCommandTest extends AbstractImportExportTestCase 'path to not existing file' => [ [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/me_does_not_exist.xml', - '--forceUid' => true + '--force-uid' => true ], 'expected' => 'File not found: ' ], 'unsupported file extension' => [ [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/unsupported.json', - '--forceUid' => true + '--force-uid' => true ], 'expected' => 'File extension "json" is not valid. Supported file extensions are "xml", "t3d".' ], 'missing required extension' => [ [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/sys_category_table_with_news.xml', - '--forceUid' => true + '--force-uid' => true ], 'expected' => 'Prerequisites for file import are not met.' ], 'missing required storage path' => [ [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-with-invalid-storage.xml', - '--forceUid' => true + '--force-uid' => true ], 'expected' => 'Prerequisites for file import are not met.' ], 'forcing uids of sys_file records not supported' => [ [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-with-forced-uids.xml', - '--forceUid' => true + '--force-uid' => true ], 'expected' => 'The import has failed.', ], 'import mode does not match associative array pattern of cli' => [ [ 'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent.xml', - '--importMode' => [sprintf('pages:987:%s', Import::IMPORT_MODE_FORCE_UID)] + '--import-mode' => [sprintf('pages:987:%s', Import::IMPORT_MODE_FORCE_UID)] ], - 'expected' => sprintf('Command line option "importMode" has invalid entry "pages:987:%s".', Import::IMPORT_MODE_FORCE_UID), + 'expected' => sprintf('Command line option "import-mode" has invalid entry "pages:987:%s".', Import::IMPORT_MODE_FORCE_UID), ], ]; } -- GitLab