TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
GroupFileAndFileReferenceItem/ImportInEmptyDatabaseTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Impexp\Tests\Functional\Import\GroupFileAndFileReferenceItem;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
26  '/uploads/tx_impexpgroupfiles'
27  ];
28 
32  protected $testExtensionsToLoad = [
33  'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
34  ];
35 
39  protected $assertionDataSetDirectory = 'typo3/sysext/impexp/Tests/Functional/Import/GroupFileAndFileReferenceItem/DataSet/Assertion/';
40 
45  {
46  $this->import->loadFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item.xml', 1);
47  $this->import->importData(0);
48 
49  $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
50  $this->testFilesToDelete[] = PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg';
51 
52  $this->assertAssertionDataSet('importGroupFileAndFileReferenceItem');
53 
54  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
55  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
56  }
57 
62  {
63  $GLOBALS['TCA']['tx_impexpgroupfiles_item']['ctrl']['rootLevel'] = 1;
64 
65  $this->import->loadFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item.xml', 1);
66  $this->import->importData(0);
67 
68  $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
69  $this->testFilesToDelete[] = PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg';
70 
71  $this->assertAssertionDataSet('importGroupFileAndFileReferenceItemWithRootLevelOnlyAllowed');
72 
73  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
74  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
75  }
76 
81  {
82  $GLOBALS['TCA']['tx_impexpgroupfiles_item']['ctrl']['rootLevel'] = 0;
83 
84  $this->import->loadFile(__DIR__ . '/ImportExportXml/impexp-group-file-and-file_reference-item-on-pid-zero.xml', 1);
85  $this->import->importData(0);
86 
87  $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
88 
89  $this->assertAssertionDataSet('importGroupFileAndFileReferenceItemWithRootLevelNotAllowed');
90 
91  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
92  $this->assertFileNotExists(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
93 
94  $expectedErrors = [
95  'Error: Record type tx_impexpgroupfiles_item is not allowed on pid 0'
96  ];
97  $errors = $this->import->errorLog;
98  $this->assertSame($expectedErrors, $errors);
99  }
100 
105  {
106  $GLOBALS['TCA']['tx_impexpgroupfiles_item']['ctrl']['rootLevel'] = -1;
107 
108  $this->import->loadFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item.xml', 1);
109  $this->import->importData(0);
110 
111  $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
112  $this->testFilesToDelete[] = PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg';
113 
114  $this->assertAssertionDataSet('importGroupFileAndFileReferenceItemWithRootLevelAndPagesAllowed');
115 
116  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
117  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
118  }
119 
124  {
125  $this->import->loadFile(PATH_site . 'typo3/sysext/impexp/Tests/Functional/Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item-but-images-not-included.xml', 1);
126  $this->import->importData(0);
127 
128  $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
129  $this->testFilesToDelete[] = PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg';
130 
131  $this->assertAssertionDataSet('importGroupFileAndFileReferenceItem');
132 
133  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
134  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
135  }
136 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']