9b84d2633aba56dfe8a59908cf4ab4f9a1469dc1
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / FAL / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL;
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 DataHandler
19 */
20 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
21 {
22 const VALUE_PageId = 89;
23 const VALUE_PageIdTarget = 90;
24 const VALUE_PageIdWebsite = 1;
25 const VALUE_ContentIdFirst = 330;
26 const VALUE_ContentIdLast = 331;
27 const VALUE_FileIdFirst = 1;
28 const VALUE_FileIdLast = 21;
29 const VALUE_LanguageId = 1;
30
31 const VALUE_FileReferenceContentFirstFileFirst = 126;
32 const VALUE_FileReferenceContentFirstFileLast = 127;
33 const VALUE_FileReferenceContentLastFileLast = 128;
34 const VALUE_FileReferenceContentLastFileFirst = 129;
35
36 const TABLE_Page = 'pages';
37 const TABLE_Content = 'tt_content';
38 const TABLE_File = 'sys_file';
39 const TABLE_FileMetadata = 'sys_file_metadata';
40 const TABLE_FileReference = 'sys_file_reference';
41
42 const FIELD_ContentImage = 'image';
43 const FIELD_FileReferenceImage = 'uid_local';
44
45 /**
46 * @var string
47 */
48 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/FAL/DataSet/';
49
50 protected function setUp()
51 {
52 parent::setUp();
53 $this->importScenarioDataSet('LiveDefaultPages');
54 $this->importScenarioDataSet('LiveDefaultElements');
55 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/sys_file_storage.xml');
56
57 $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
58 $this->backendUser->workspace = 0;
59 }
60
61 /**
62 * Content records
63 */
64
65 /**
66 * @see DataSet/Assertion/modifyContentRecord.csv
67 */
68 public function modifyContent()
69 {
70 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
71 }
72
73 /**
74 * @see DataSet/Assertion/deleteContentRecord.csv
75 */
76 public function deleteContent()
77 {
78 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
79 }
80
81 /**
82 * @see DataSet/Assertion/copyContentRecord.csv
83 */
84 public function copyContent()
85 {
86 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
87 $this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
88 }
89
90 /**
91 * @see DataSet/Assertion/localizeContentRecord.csv
92 */
93 public function localizeContent()
94 {
95 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
96 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
97 }
98
99 /**
100 * @see DataSet/Assertion/changeContentRecordSorting.csv
101 */
102 public function changeContentSorting()
103 {
104 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
105 }
106
107 /**
108 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
109 */
110 public function moveContentToDifferentPage()
111 {
112 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
113 }
114
115 /**
116 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
117 */
118 public function moveContentToDifferentPageAndChangeSorting()
119 {
120 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
121 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
122 }
123
124 /**
125 * File references
126 */
127
128 public function createContentWithFileReference()
129 {
130 $newTableIds = $this->actionService->createNewRecords(
131 self::VALUE_PageId,
132 array(
133 self::TABLE_Content => array('header' => 'Testing #1', self::FIELD_ContentImage => '__nextUid'),
134 self::TABLE_FileReference => array('title' => 'Image #1', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst),
135 )
136 );
137 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
138 }
139
140 public function modifyContentWithFileReference()
141 {
142 $this->actionService->modifyRecords(
143 self::VALUE_PageId,
144 array(
145 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'header' => 'Testing #1', self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst),
146 self::TABLE_FileReference => array('uid' => self::VALUE_FileReferenceContentLastFileFirst, 'title' => 'Image #1'),
147 )
148 );
149 }
150
151 public function modifyContentAndAddFileReference()
152 {
153 $this->actionService->modifyRecords(
154 self::VALUE_PageId,
155 array(
156 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst . ',__nextUid'),
157 self::TABLE_FileReference => array('uid' => '__NEW', 'title' => 'Image #3', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst),
158 )
159 );
160 }
161
162 public function modifyContentAndDeleteFileReference()
163 {
164 $this->actionService->modifyRecord(
165 self::TABLE_Content,
166 self::VALUE_ContentIdLast,
167 array(self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileFirst),
168 array(self::TABLE_FileReference => array(self::VALUE_FileReferenceContentLastFileLast))
169 );
170 }
171
172 public function modifyContentAndDeleteAllFileReference()
173 {
174 $this->actionService->modifyRecord(
175 self::TABLE_Content,
176 self::VALUE_ContentIdLast,
177 array(self::FIELD_ContentImage => ''),
178 array(self::TABLE_FileReference => array(self::VALUE_FileReferenceContentLastFileFirst, self::VALUE_FileReferenceContentLastFileLast))
179 );
180 }
181 }