[CLEANUP] Remove obsolete require_once from test files
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Tests / Functional / Import / GroupFileAndFileReferenceItem / ImportInEmptyDatabaseTest.php
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
17 /**
18 * Functional test for the ImportExport
19 */
20 class ImportInEmptyDatabaseTest extends \TYPO3\CMS\Impexp\Tests\Functional\Import\AbstractImportTestCase {
21
22 /**
23 * @var array
24 */
25 protected $additionalFoldersToCreate = array(
26 '/uploads/tx_impexpgroupfiles'
27 );
28
29 /**
30 * @var array
31 */
32 protected $testExtensionsToLoad = array(
33 'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
34 );
35
36 /**
37 * @var string
38 */
39 protected $assertionDataSetDirectory = 'typo3/sysext/impexp/Tests/Functional/Import/GroupFileAndFileReferenceItem/DataSet/Assertion/';
40
41 /**
42 * @test
43 */
44 public function importGroupFileAndFileReferenceItem() {
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
58 /**
59 * @test
60 */
61 public function importGroupFileAndFileReferenceItemWithRootLevelOnlyAllowed() {
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
77 /**
78 * @test
79 */
80 public function importGroupFileAndFileReferenceItemWithRootLevelNotAllowed() {
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 = array(
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
101 /**
102 * @test
103 */
104 public function importGroupFileAndFileReferenceItemWithRootLevelAndPagesAllowed() {
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
112 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
113 $this->testFilesToDelete[] = PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg';
114
115 $this->assertAssertionDataSet('importGroupFileAndFileReferenceItemWithRootLevelAndPagesAllowed');
116
117 $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
118 $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
119 }
120
121 /**
122 * @test
123 */
124 public function importGroupFileAndFileReferenceItemButImagesNotIncluded() {
125
126 $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);
127 $this->import->importData(0);
128
129 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image5.jpg';
130 $this->testFilesToDelete[] = PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg';
131
132 $this->assertAssertionDataSet('importGroupFileAndFileReferenceItem');
133
134 $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', PATH_site . 'fileadmin/user_upload/typo3_image5.jpg');
135 $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg');
136 }
137
138 }