‪TYPO3CMS  ‪main
ExportCommandTest.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;
25 
27 {
31  public function ‪exportCommandRequiresNoArguments(): void
32  {
33  $exportMock = $this->getAccessibleMock(Export::class, ['setMetaData']);
34  $tester = new CommandTester(new ‪ExportCommand($exportMock));
35  $tester->execute([], []);
36 
37  self::assertEquals(0, $tester->getStatusCode());
38  }
39 
44  {
45  $fileName = 'empty_export';
46 
47  $exportMock = $this->getAccessibleMock(Export::class, ['setMetaData']);
48  $tester = new CommandTester(new ‪ExportCommand($exportMock));
49  $tester->execute(['filename' => $fileName], []);
50 
51  preg_match('/([^\s]*importexport[^\s]*)/', $tester->getDisplay(), $display);
52  $filePath = ‪Environment::getPublicPath() . '/' . $display[1];
53 
54  self::assertEquals(0, $tester->getStatusCode());
55  self::assertStringEndsWith('empty_export.xml', $filePath);
56  self::assertXmlFileEqualsXmlFile(__DIR__ . '/../Fixtures/XmlExports/empty.xml', $filePath);
57  }
58 
63  {
64  $input = [
65  'filename' => 'empty_export',
66  '--type' => ‪Export::FILETYPE_T3D,
67  '--pid' => 123,
69  '--table' => ['tt_content'],
70  '--record' => ['sys_category:6'],
71  '--list' => ['sys_category:123'],
72  '--include-related' => ['be_users'],
73  '--include-static' => ['sys_category'],
74  '--exclude' => ['be_users:3'],
75  '--exclude-disabled-records' => false,
76  '--exclude-html-css' => false,
77  '--title' => 'Export Command',
78  '--description' => 'The export which considers all arguments passed on the command line.',
79  '--notes' => 'This export is not for production use.',
80  '--dependency' => ['bootstrap_package'],
81  '--save-files-outside-export-file' => false,
82  ];
83 
84  $exportMock = $this->getAccessibleMock(Export::class, [
85  'setExportFileType', 'setExportFileName', 'setPid', 'setLevels', 'setTables', 'setRecord', 'setList',
86  'setRelOnlyTables', 'setRelStaticTables', 'setExcludeMap', 'setExcludeDisabledRecords',
87  'setIncludeExtFileResources', 'setTitle', 'setDescription', 'setNotes', 'setExtensionDependencies',
88  'setSaveFilesOutsideExportFile',
89  ]);
90  $exportMock->expects(self::once())->method('setExportFileName')->with(self::equalTo('empty_export'));
91  $exportMock->expects(self::once())->method('setExportFileType')->with(self::equalTo(‪Export::FILETYPE_T3D));
92  $exportMock->expects(self::once())->method('setPid')->with(self::equalTo(123));
93  $exportMock->expects(self::once())->method('setLevels')->with(self::equalTo(‪Export::LEVELS_RECORDS_ON_THIS_PAGE));
94  $exportMock->expects(self::once())->method('setTables')->with(self::equalTo(['tt_content']));
95  $exportMock->expects(self::once())->method('setRecord')->with(self::equalTo(['sys_category:6']));
96  $exportMock->expects(self::once())->method('setList')->with(self::equalTo(['sys_category:123']));
97  $exportMock->expects(self::once())->method('setRelOnlyTables')->with(self::equalTo(['be_users']));
98  $exportMock->expects(self::once())->method('setRelStaticTables')->with(self::equalTo(['sys_category']));
99  $exportMock->expects(self::once())->method('setExcludeMap')->with(self::equalTo(['be_users:3']));
100  $exportMock->expects(self::once())->method('setExcludeDisabledRecords')->with(self::equalTo(false));
101  $exportMock->expects(self::once())->method('setIncludeExtFileResources')->with(self::equalTo(true));
102  $exportMock->expects(self::once())->method('setTitle')->with(self::equalTo('Export Command'));
103  $exportMock->expects(self::once())->method('setDescription')->with(self::equalTo('The export which considers all arguments passed on the command line.'));
104  $exportMock->expects(self::once())->method('setNotes')->with(self::equalTo('This export is not for production use.'));
105  $exportMock->expects(self::once())->method('setExtensionDependencies')->with(self::equalTo(['bootstrap_package']));
106  $exportMock->expects(self::once())->method('setSaveFilesOutsideExportFile')->with(self::equalTo(false));
107 
108  $tester = new CommandTester(new ‪ExportCommand($exportMock));
109  $tester->execute($input);
110  }
111 }
‪TYPO3\CMS\Impexp\Tests\Functional\Command\ExportCommandTest\exportCommandPassesArgumentsToExportObject
‪exportCommandPassesArgumentsToExportObject()
Definition: ExportCommandTest.php:62
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Impexp\Tests\Functional\Command\ExportCommandTest
Definition: ExportCommandTest.php:27
‪TYPO3\CMS\Impexp\Export\FILETYPE_T3D
‪const FILETYPE_T3D
Definition: Export.php:57
‪TYPO3\CMS\Impexp\Export\LEVELS_RECORDS_ON_THIS_PAGE
‪const LEVELS_RECORDS_ON_THIS_PAGE
Definition: Export.php:52
‪TYPO3\CMS\Impexp\Tests\Functional\Command\ExportCommandTest\exportCommandRequiresNoArguments
‪exportCommandRequiresNoArguments()
Definition: ExportCommandTest.php:31
‪TYPO3\CMS\Impexp\Tests\Functional\Command\ExportCommandTest\exportCommandSavesExportWithGivenFileName
‪exportCommandSavesExportWithGivenFileName()
Definition: ExportCommandTest.php:43
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:33
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Impexp\Export
Definition: Export.php:51
‪TYPO3\CMS\Impexp\Command\ExportCommand
Definition: ExportCommand.php:34
‪TYPO3\CMS\Impexp\Tests\Functional\Command
Definition: ExportCommandTest.php:18