[BUGFIX] Fix executable permissions on files
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Tests / Functional / ImportExport / ExportSimpleTest.php
1 <?php
2 namespace TYPO3\CMS\Impexp\Tests\Functional\ImportExport;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Marc Bastian Heinrichs <typo3@mbh-software.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Core\Utility\GeneralUtility;
28 use TYPO3\CMS\Backend\Utility\BackendUtility;
29
30 /**
31 * Functional test for the ImportExport
32 */
33 class ExportSimpleTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
34
35 /**
36 * @var array
37 */
38 protected $coreExtensionsToLoad = array('impexp');
39
40 public function setUp() {
41 parent::setUp();
42 $this->setUpBackendUserFromFixture(1);
43 // Needed to avoid PHP Warnings
44 $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'] = array();
45 $this->importDataSet(__DIR__ . '/../Fixtures/Database/pages.xml');
46 $this->importDataSet(__DIR__ . '/../Fixtures/Database/tt_content.xml');
47 }
48
49 /**
50 * @test
51 */
52 public function canExportSimplePagesAndRelatedTtContent() {
53 $permsClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
54
55 /** @var $export \TYPO3\CMS\Impexp\ImportExport */
56 $export = GeneralUtility::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport');
57 $export->init(0, 'export');
58
59 $export->setRecordTypesIncludeFields(
60 array(
61 'pages' => array(
62 'title',
63 'deleted',
64 'doktype',
65 'hidden',
66 'perms_everybody'
67 ),
68 'tt_content' => array(
69 'CType',
70 'header',
71 'deleted',
72 'hidden',
73 't3ver_oid'
74 )
75 )
76 );
77
78 $export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
79 $export->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
80 $export->export_addRecord('tt_content', BackendUtility::getRecord('tt_content', 1));
81
82 $pidToStart = 1;
83 /** @var $tree \TYPO3\CMS\Backend\Tree\View\PageTreeView */
84 $tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
85 $tree->init('AND ' . $permsClause);
86 $tree->tree[] = array('row' => $pidToStart);
87 $tree->buffer_idH = array();
88 $tree->getTree(1, 1, '');
89
90 $idH = array();
91 $idH[$pidToStart]['uid'] = $pidToStart;
92 if (count($tree->buffer_idH)) {
93 $idH[$pidToStart]['subrow'] = $tree->buffer_idH;
94 }
95 $export->setPageTree($idH);
96
97 // After adding ALL records we set relations:
98 for ($a = 0; $a < 10; $a++) {
99 $addR = $export->export_addDBRelations($a);
100 if (!count($addR)) {
101 break;
102 }
103 }
104
105 $export->export_addFilesFromRelations();
106
107 $out = $export->compileMemoryToFileContent('xml');
108
109 $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../Fixtures/ImportExport/pages-and-ttcontent.xml', $out);
110 }
111
112 }