[BUGFIX] Correct typo of ActionService->getDataHandler()
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / Regular / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular;
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 require_once __DIR__ . '/../../../../../core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php';
18
19 /**
20 * Functional test for the DataHandler
21 */
22 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase {
23
24 const VALUE_PageId = 89;
25 const VALUE_PageIdTarget = 90;
26 const VALUE_PageIdWebsite = 1;
27 const VALUE_ContentIdFirst = 297;
28 const VALUE_ContentIdSecond = 298;
29 const VALUE_ContentIdThird = 299;
30 const VALUE_ContentIdThirdLocalized = 300;
31 const VALUE_LanguageId = 1;
32 const VALUE_WorkspaceId = 1;
33
34 const TABLE_Page = 'pages';
35 const TABLE_PageOverlay = 'pages_language_overlay';
36 const TABLE_Content = 'tt_content';
37
38 /**
39 * @var array
40 */
41 protected $coreExtensionsToLoad = array(
42 'fluid',
43 'version',
44 'workspaces',
45 );
46
47 /**
48 * @var string
49 */
50 protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/';
51
52 public function setUp() {
53 parent::setUp();
54 $this->importScenarioDataSet('LiveDefaultPages');
55 $this->importScenarioDataSet('LiveDefaultElements');
56 $this->importScenarioDataSet('ReferenceIndex');
57
58 $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
59 $this->backendUser->workspace = self::VALUE_WorkspaceId;
60 }
61
62 /**
63 * Content records
64 */
65
66 /**
67 * @see DataSet/Assertion/createContentRecords.csv
68 */
69 public function createContents() {
70 // Creating record at the beginning of the page
71 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
72 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][0];
73 // Creating record at the end of the page (after last one)
74 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, -self::VALUE_ContentIdSecond, array('header' => 'Testing #2'));
75 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][0];
76 }
77
78 /**
79 * @see DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv
80 */
81 public function createContentAndDiscardCreatedContent() {
82 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
83 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
84 $versionedNewContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['newContentId']);
85 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId);
86 }
87
88 /**
89 * @see DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv
90 */
91 public function createAndCopyContentAndDiscardCopiedContent() {
92 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
93 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
94 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $this->recordIds['newContentId'], self::VALUE_PageId);
95 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][$this->recordIds['newContentId']];
96 $versionedCopiedContentId = $this->actionService->getDataHandler()->getAutoVersionId(self::TABLE_Content, $this->recordIds['copiedContentId']);
97 $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
98 }
99
100 /**
101 * @see DataSet/Assertion/modifyContentRecord.csv
102 */
103 public function modifyContent() {
104 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, array('header' => 'Testing #1'));
105 }
106
107 /**
108 * @see DataSet/Assertion/deleteContentRecord.csv
109 */
110 public function deleteContent() {
111 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
112 }
113
114 /**
115 * @see DataSet/deleteLocalizedContentNDeleteContent.csv
116 */
117 public function deleteLocalizedContentAndDeleteContent() {
118 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized);
119 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdThird);
120 }
121
122 /**
123 * @see DataSet/Assertion/copyContentRecord.csv
124 */
125 public function copyContent() {
126 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageId);
127 $this->recordIds['copiedContentId'] = $copiedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
128 }
129
130 /**
131 * @see DataSet/Assertion/localizeContentRecord.csv
132 */
133 public function localizeContent() {
134 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_LanguageId);
135 $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
136 }
137
138 /**
139 * @see DataSet/Assertion/changeContentRecordSorting.csv
140 */
141 public function changeContentSorting() {
142 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
143 }
144
145 /**
146 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
147 */
148 public function moveContentToDifferentPage() {
149 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
150 }
151
152 /**
153 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
154 */
155 public function moveContentToDifferentPageAndChangeSorting() {
156 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, self::VALUE_PageIdTarget);
157 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdSecond);
158 }
159
160 /**
161 * Page records
162 */
163
164 /**
165 * @see DataSet/Assertion/createPageRecord.csv
166 */
167 public function createPage() {
168 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1', 'hidden' => 0));
169 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
170 }
171
172 /**
173 * @see DataSet/Assertion/modifyPageRecord.csv
174 */
175 public function modifyPage() {
176 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
177 }
178
179 /**
180 * @see DataSet/Assertion/deletePageRecord.csv
181 */
182 public function deletePage() {
183 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
184 }
185
186 /**
187 * @see DataSet/Assertion/copyPageRecord.csv
188 */
189 public function copyPage() {
190 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
191 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
192 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
193 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdSecond];
194 }
195
196 /**
197 * @see DataSet/Assertion/localizePageRecord.csv
198 */
199 public function localizePage() {
200 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
201 $this->recordIds['localizedPageOverlayId'] = $localizedTableIds[self::TABLE_PageOverlay][self::VALUE_PageId];
202 }
203
204 /**
205 * @see DataSet/Assertion/changePageRecordSorting.csv
206 */
207 public function changePageSorting() {
208 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
209 }
210
211 /**
212 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
213 */
214 public function movePageToDifferentPage() {
215 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
216 }
217
218 /**
219 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
220 */
221 public function movePageToDifferentPageAndChangeSorting() {
222 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
223 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageId, -self::VALUE_PageIdTarget);
224 }
225
226 /**
227 * @see DataSet/Assertion/movePageRecordToDifferentPageAndCreatePageRecordAfterMovedPageRecord.csv
228 * @see http://forge.typo3.org/issues/33104
229 * @see http://forge.typo3.org/issues/55573
230 */
231 public function movePageToDifferentPageAndCreatePageAfterMovedPage() {
232 $this->actionService->moveRecord(self::TABLE_Page, self::VALUE_PageIdTarget, self::VALUE_PageIdWebsite);
233 $newTableIds = $this->actionService->createNewRecord(self::TABLE_Page, -self::VALUE_PageIdTarget, array('title' => 'Testing #1', 'hidden' => 0));
234 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][0];
235 }
236
237 }