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