b860a649147d88fcc81a1be652827fa45e3a6479
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / ManyToMany / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\Modify;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Oliver Hader <oliver.hader@typo3.org>
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 require_once dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
28
29 /**
30 * Functional test for the DataHandler
31 */
32 class ActionTest extends \TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/ManyToMany/Modify/DataSet/';
38
39 /**
40 * MM Relations
41 */
42
43 /**
44 * @test
45 * @see DataSet/Assertion/addCategoryRelation.csv
46 */
47 public function addCategoryRelation() {
48 parent::addCategoryRelation();
49 $this->assertAssertionDataSet('addCategoryRelation');
50
51 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
52 $this->assertResponseContentStructureHasRecords(
53 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
54 self::TABLE_Category, 'title', array('Category A', 'Category B', 'Category A.A')
55 );
56 }
57
58 /**
59 * @test
60 * @see DataSet/Assertion/deleteCategoryRelation.csv
61 */
62 public function deleteCategoryRelation() {
63 parent::deleteCategoryRelation();
64 $this->assertAssertionDataSet('deleteCategoryRelation');
65
66 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
67 $this->assertResponseContentStructureHasRecords(
68 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
69 self::TABLE_Category, 'title', array('Category A')
70 );
71 $this->assertResponseContentStructureDoesNotHaveRecords(
72 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
73 self::TABLE_Category, 'title', array('Category B', 'Category C', 'Category A.A')
74 );
75 }
76
77 /**
78 * @test
79 * @see DataSet/Assertion/changeCategoryRelationSorting.csv
80 */
81 public function changeCategoryRelationSorting() {
82 parent::changeCategoryRelationSorting();
83 $this->assertAssertionDataSet('changeCategoryRelationSorting');
84
85 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
86 $this->assertResponseContentStructureHasRecords(
87 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
88 self::TABLE_Category, 'title', array('Category A', 'Category B')
89 );
90 }
91
92 /**
93 * @test
94 * @see DataSet/Assertion/createContentRecordAndAddCategoryRelation.csv
95 */
96 public function createContentAndAddRelation() {
97 parent::createContentAndAddRelation();
98 $this->assertAssertionDataSet('createContentNAddRelation');
99
100 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
101 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
102 $this->assertResponseContentStructureHasRecords(
103 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
104 self::TABLE_Category, 'title', 'Category B'
105 );
106 }
107
108 /**
109 * @test
110 * @see DataSet/Assertion/createCategoryRecordAndAddCategoryRelation.csv
111 */
112 public function createCategoryAndAddRelation() {
113 parent::createCategoryAndAddRelation();
114 $this->assertAssertionDataSet('createCategoryNAddRelation');
115
116 // @todo Does not work due to the core bug of not setting the reference field in the MM record
117 /*
118 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
119 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Category, 'title', 'Testing #1');
120 $this->assertResponseContentStructureHasRecords(
121 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
122 self::TABLE_Category, 'title', 'Testing #1'
123 );
124 */
125 }
126
127 /**
128 * @test
129 * @see DataSet/Assertion/createContentRecordAndCreateCategoryRelation.csv
130 */
131 public function createContentAndCreateRelation() {
132 parent::createContentAndCreateRelation();
133 $this->assertAssertionDataSet('createContentNCreateRelation');
134
135 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
136 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
137
138 // @todo New category is not resolved in new content element due to core bug
139 // The frontend query ignores pid=-1 and thus the specific workspace record in sys_category:33
140 /*
141 $this->assertResponseContentStructureHasRecords(
142 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
143 self::TABLE_Category, 'title', 'Testing #1'
144 );
145 */
146 }
147
148 /**
149 * @test
150 * @see DataSet/Assertion/createCategoryRecordAndCreateCategoryRelation.csv
151 */
152 public function createCategoryAndCreateRelation() {
153 parent::createCategoryAndCreateRelation();
154 $this->assertAssertionDataSet('createCategoryNCreateRelation');
155 }
156
157 /**
158 * @test
159 * @see DataSet/Assertion/modifyCategoryRecordOfCategoryRelation.csv
160 */
161 public function modifyCategoryOfRelation() {
162 parent::modifyCategoryOfRelation();
163 $this->assertAssertionDataSet('modifyCategoryOfRelation');
164
165 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
166 $this->assertResponseContentStructureHasRecords(
167 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
168 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
169 );
170 }
171
172 /**
173 * @test
174 * @see DataSet/Assertion/modifyContentRecordOfCategoryRelation.csv
175 */
176 public function modifyContentOfRelation() {
177 parent::modifyContentOfRelation();
178 $this->assertAssertionDataSet('modifyContentOfRelation');
179
180 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
181 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
182 }
183
184 /**
185 * @test
186 * @see DataSet/Assertion/modifyBothRecordsOfCategoryRelation.csv
187 */
188 public function modifyBothsOfRelation() {
189 parent::modifyBothsOfRelation();
190 $this->assertAssertionDataSet('modifyBothsOfRelation');
191
192 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
193 $this->assertResponseContentStructureHasRecords(
194 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
195 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
196 );
197 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
198 }
199
200 /**
201 * @test
202 * @see DataSet/Assertion/deleteContentRecordOfCategoryRelation.csv
203 */
204 public function deleteContentOfRelation() {
205 parent::deleteContentOfRelation();
206 $this->assertAssertionDataSet('deleteContentOfRelation');
207
208 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
209 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
210 }
211
212 /**
213 * @test
214 * @see DataSet/Assertion/deleteCategoryRecordOfCategoryRelation.csv
215 */
216 public function deleteCategoryOfRelation() {
217 parent::deleteCategoryOfRelation();
218 $this->assertAssertionDataSet('deleteCategoryOfRelation');
219
220 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
221 $this->assertResponseContentStructureDoesNotHaveRecords(
222 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
223 self::TABLE_Category, 'title', array('Category A')
224 );
225 }
226
227 /**
228 * @test
229 * @see DataSet/Assertion/copyContentRecordOfCategoryRelation.csv
230 */
231 public function copyContentOfRelation() {
232 parent::copyContentOfRelation();
233 $this->assertAssertionDataSet('copyContentOfRelation');
234
235 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
236 $this->assertResponseContentStructureHasRecords(
237 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
238 self::TABLE_Category, 'title', array('Category B', 'Category C')
239 );
240 }
241
242 /**
243 * @test
244 * @see DataSet/Assertion/copyCategoryRecordOfCategoryRelation.csv
245 */
246 public function copyCategoryOfRelation() {
247 parent::copyCategoryOfRelation();
248 $this->assertAssertionDataSet('copyCategoryOfRelation');
249
250 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
251 $this->assertResponseContentStructureHasRecords(
252 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
253 self::TABLE_Category, 'title', 'Category A'
254 // @todo Actually it should be twice "Category A" since the category got copied
255 // The frontend query ignores pid=-1 and thus the specific workspace record in sys_category:33
256 // SELECT sys_category.* FROM sys_category JOIN sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid WHERE sys_category.uid IN (33,28,29)
257 // AND sys_category_record_mm.uid_foreign=297 AND (sys_category.sys_language_uid IN (0,-1))
258 // AND sys_category.deleted=0 AND (sys_category.t3ver_wsid=0 OR sys_category.t3ver_wsid=1) AND sys_category.pid<>-1
259 // ORDER BY sys_category_record_mm.sorting_foreign
260 // self::TABLE_Category, 'title', array('Category A', 'Category A')
261 );
262 }
263
264 /**
265 * @test
266 * @see DataSet/Assertion/localizeContentRecordOfCategoryRelation.csv
267 */
268 public function localizeContentOfRelation() {
269 parent::localizeContentOfRelation();
270 $this->assertAssertionDataSet('localizeContentOfRelation');
271
272 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
273 $this->assertResponseContentStructureHasRecords(
274 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
275 self::TABLE_Category, 'title', array('Category B', 'Category C')
276 );
277 }
278
279 /**
280 * @test
281 * @see DataSet/Assertion/localizeCategoryRecordOfCategoryRelation.csv
282 */
283 public function localizeCategoryOfRelation() {
284 parent::localizeCategoryOfRelation();
285 $this->assertAssertionDataSet('localizeCategoryOfRelation');
286
287 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
288 $this->assertResponseContentStructureHasRecords(
289 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
290 self::TABLE_Category, 'title', array('[Translate to Dansk:] Category A', 'Category B')
291 );
292 }
293
294 /**
295 * @test
296 * @see DataSet/Assertion/moveContentRecordOfCategoryRelationToDifferentPage.csv
297 */
298 public function moveContentOfRelationToDifferentPage() {
299 parent::moveContentOfRelationToDifferentPage();
300 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
301
302 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
303 $this->assertResponseContentStructureHasRecords(
304 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
305 self::TABLE_Category, 'title', array('Category B', 'Category C')
306 );
307 }
308
309 /**
310 * @test
311 * @see DataSet/Assertion/copyPage.csv
312 */
313 public function copyPage() {
314 parent::copyPage();
315 $this->assertAssertionDataSet('copyPage');
316
317 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'], 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
318 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Relations');
319 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
320 $this->assertResponseContentStructureHasRecords(
321 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'], 'categories',
322 self::TABLE_Category, 'title', array('Category A', 'Category B')
323 );
324 $this->assertResponseContentStructureHasRecords(
325 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'], 'categories',
326 self::TABLE_Category, 'title', array('Category B', 'Category C')
327 );
328 }
329
330 }