1c36171decd9822edf99525c7af58e14916e4fd4
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / ManyToMany / PublishAll / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll;
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/PublishAll/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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
139 $this->assertAssertionDataSet('createContentNCreateRelation');
140
141 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
142 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
143
144 // @todo New category is not resolved in new content element due to core bug
145 // The frontend query ignores pid=-1 and thus the specific workspace record in sys_category:33
146 /*
147 $this->assertResponseContentStructureHasRecords(
148 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
149 self::TABLE_Category, 'title', 'Testing #1'
150 );
151 */
152 }
153
154 /**
155 * @test
156 * @see DataSet/Assertion/createCategoryRecordAndCreateCategoryRelation.csv
157 */
158 public function createCategoryAndCreateRelation() {
159 parent::createCategoryAndCreateRelation();
160 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
161 $this->assertAssertionDataSet('createCategoryNCreateRelation');
162 }
163
164 /**
165 * @test
166 * @see DataSet/Assertion/modifyCategoryRecordOfCategoryRelation.csv
167 */
168 public function modifyCategoryOfRelation() {
169 parent::modifyCategoryOfRelation();
170 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
171 $this->assertAssertionDataSet('modifyCategoryOfRelation');
172
173 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
174 $this->assertResponseContentStructureHasRecords(
175 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
176 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
177 );
178 }
179
180 /**
181 * @test
182 * @see DataSet/Assertion/modifyContentRecordOfCategoryRelation.csv
183 */
184 public function modifyContentOfRelation() {
185 parent::modifyContentOfRelation();
186 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
187 $this->assertAssertionDataSet('modifyContentOfRelation');
188
189 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
190 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
191 }
192
193 /**
194 * @test
195 * @see DataSet/Assertion/modifyBothRecordsOfCategoryRelation.csv
196 */
197 public function modifyBothsOfRelation() {
198 parent::modifyBothsOfRelation();
199 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
200 $this->assertAssertionDataSet('modifyBothsOfRelation');
201
202 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
203 $this->assertResponseContentStructureHasRecords(
204 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
205 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
206 );
207 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
208 }
209
210 /**
211 * @test
212 * @see DataSet/Assertion/deleteContentRecordOfCategoryRelation.csv
213 */
214 public function deleteContentOfRelation() {
215 parent::deleteContentOfRelation();
216 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
217 $this->assertAssertionDataSet('deleteContentOfRelation');
218
219 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
220 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
221 }
222
223 /**
224 * @test
225 * @see DataSet/Assertion/deleteCategoryRecordOfCategoryRelation.csv
226 */
227 public function deleteCategoryOfRelation() {
228 parent::deleteCategoryOfRelation();
229 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
230 $this->assertAssertionDataSet('deleteCategoryOfRelation');
231
232 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
233 $this->assertResponseContentStructureDoesNotHaveRecords(
234 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
235 self::TABLE_Category, 'title', array('Category A')
236 );
237 }
238
239 /**
240 * @test
241 * @see DataSet/Assertion/copyContentRecordOfCategoryRelation.csv
242 */
243 public function copyContentOfRelation() {
244 parent::copyContentOfRelation();
245 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
246 $this->assertAssertionDataSet('copyContentOfRelation');
247
248 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
249 $this->assertResponseContentStructureHasRecords(
250 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
251 self::TABLE_Category, 'title', array('Category B', 'Category C')
252 );
253 }
254
255 /**
256 * @test
257 * @see DataSet/Assertion/copyCategoryRecordOfCategoryRelation.csv
258 */
259 public function copyCategoryOfRelation() {
260 parent::copyCategoryOfRelation();
261 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
262 $this->assertAssertionDataSet('copyCategoryOfRelation');
263
264 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
265 $this->assertResponseContentStructureHasRecords(
266 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
267 self::TABLE_Category, 'title', 'Category A'
268 // @todo Actually it should be twice "Category A" since the category got copied
269 // The frontend query ignores pid=-1 and thus the specific workspace record in sys_category:33
270 // 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)
271 // AND sys_category_record_mm.uid_foreign=297 AND (sys_category.sys_language_uid IN (0,-1))
272 // AND sys_category.deleted=0 AND (sys_category.t3ver_wsid=0 OR sys_category.t3ver_wsid=1) AND sys_category.pid<>-1
273 // ORDER BY sys_category_record_mm.sorting_foreign
274 // self::TABLE_Category, 'title', array('Category A', 'Category A')
275 );
276 }
277
278 /**
279 * @test
280 * @see DataSet/Assertion/localizeContentRecordOfCategoryRelation.csv
281 */
282 public function localizeContentOfRelation() {
283 parent::localizeContentOfRelation();
284 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
285 $this->assertAssertionDataSet('localizeContentOfRelation');
286
287 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
288 $this->assertResponseContentStructureHasRecords(
289 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
290 self::TABLE_Category, 'title', array('Category B', 'Category C')
291 );
292 }
293
294 /**
295 * @test
296 * @see DataSet/Assertion/localizeCategoryRecordOfCategoryRelation.csv
297 */
298 public function localizeCategoryOfRelation() {
299 parent::localizeCategoryOfRelation();
300 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
301 $this->assertAssertionDataSet('localizeCategoryOfRelation');
302
303 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
304 $this->assertResponseContentStructureHasRecords(
305 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
306 self::TABLE_Category, 'title', array('[Translate to Dansk:] Category A', 'Category B')
307 );
308 }
309
310 /**
311 * @test
312 * @see DataSet/Assertion/moveContentRecordOfCategoryRelationToDifferentPage.csv
313 */
314 public function moveContentOfRelationToDifferentPage() {
315 parent::moveContentOfRelationToDifferentPage();
316 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
317 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
318
319 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseContent();
320 $this->assertResponseContentStructureHasRecords(
321 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
322 self::TABLE_Category, 'title', array('Category B', 'Category C')
323 );
324 }
325
326 /**
327 * @test
328 * @see DataSet/Assertion/copyPage.csv
329 */
330 public function copyPage() {
331 parent::copyPage();
332 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
333 $this->assertAssertionDataSet('copyPage');
334
335 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseContent();
336 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Relations');
337 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
338 $this->assertResponseContentStructureHasRecords(
339 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'], 'categories',
340 self::TABLE_Category, 'title', array('Category A', 'Category B')
341 );
342 $this->assertResponseContentStructureHasRecords(
343 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'], 'categories',
344 self::TABLE_Category, 'title', array('Category B', 'Category C')
345 );
346 }
347
348 }