‪TYPO3CMS  11.5
ImportCommandTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Console\Tester\CommandTester;
24 
26 {
31  {
32  $input = [
33  'file' => 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/sys_language.xml',
34  'pid' => 3,
35  // @deprecated since v11, will be removed in v12. Drop the lowerCamelCase options.
36  '--update-records' => false,
37  '--updateRecords' => true,
38  '--ignore-pid' => false,
39  '--ignorePid' => true,
40  '--force-uid' => false,
41  '--forceUid' => true,
42  '--enable-log' => false,
43  '--enableLog' => true,
44  '--import-mode' => [
45  sprintf('pages:789=%s', ‪Import::IMPORT_MODE_FORCE_UID),
46  sprintf('tt_content:1=%s', ‪Import::IMPORT_MODE_EXCLUDE),
47  ],
48  '--importMode' => [
49  sprintf('pages:987=%s', ‪Import::IMPORT_MODE_FORCE_UID),
50  sprintf('tt_content:1=%s', ‪Import::IMPORT_MODE_AS_NEW),
51  ],
52  ];
53 
54  $importMock = $this->getAccessibleMock(Import::class, [
55  'setPid', 'setUpdate', 'setGlobalIgnorePid', 'setForceAllUids', 'setEnableLogging', 'loadFile',
56  'setImportMode',
57  ]);
58 
59  $importMock->expects(self::once())->method('setPid')->with(self::equalTo(3));
60  $importMock->expects(self::once())->method('setUpdate')->with(self::equalTo(true));
61  $importMock->expects(self::once())->method('setGlobalIgnorePid')->with(self::equalTo(true));
62  $importMock->expects(self::once())->method('setForceAllUids')->with(self::equalTo(true));
63  $importMock->expects(self::once())->method('setEnableLogging')->with(self::equalTo(true));
64  $importMock->expects(self::once())->method('setImportMode')->with(self::equalTo([
65  'pages:987' => ‪Import::IMPORT_MODE_FORCE_UID,
66  'tt_content:1' => ‪Import::IMPORT_MODE_EXCLUDE,
67  'pages:789' => ‪Import::IMPORT_MODE_FORCE_UID,
68  ]));
69  $importMock->expects(self::once())->method('loadFile')->with(self::equalTo('EXT:impexp/Tests/Functional/Fixtures/XmlImports/sys_language.xml'));
70 
71  $tester = new CommandTester(new ‪ImportCommand($importMock));
72  $tester->execute($input);
73  }
74 }
‪TYPO3\CMS\Impexp\Import\IMPORT_MODE_AS_NEW
‪const IMPORT_MODE_AS_NEW
Definition: Import.php:52
‪TYPO3\CMS\Impexp\Command\ImportCommand
Definition: ImportCommand.php:34
‪TYPO3\CMS\Impexp\Import\IMPORT_MODE_FORCE_UID
‪const IMPORT_MODE_FORCE_UID
Definition: Import.php:51
‪TYPO3\CMS\Impexp\Import\IMPORT_MODE_EXCLUDE
‪const IMPORT_MODE_EXCLUDE
Definition: Import.php:53
‪TYPO3\CMS\Impexp\Import
Definition: Import.php:50
‪TYPO3\CMS\Impexp\Tests\FunctionalDeprecated\Command
Definition: ExportCommandTest.php:18
‪TYPO3\CMS\Impexp\Tests\FunctionalDeprecated\Command\ImportCommandTest\importCommandPassesArgumentsToImportObject
‪importCommandPassesArgumentsToImportObject()
Definition: ImportCommandTest.php:30
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:34
‪TYPO3\CMS\Impexp\Tests\FunctionalDeprecated\Command\ImportCommandTest
Definition: ImportCommandTest.php:26