[BUGFIX] Invalid relations of MM records in workspaces
[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 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
122 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Category, 'title', 'Testing #1');
123 $this->assertResponseContentStructureHasRecords(
124 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
125 self::TABLE_Category, 'title', 'Testing #1'
126 );
127 }
128
129 /**
130 * @test
131 * @see DataSet/Assertion/createContentRecordAndCreateCategoryRelation.csv
132 */
133 public function createContentAndCreateRelation() {
134 parent::createContentAndCreateRelation();
135 $this->actionService->publishRecords(
136 array(
137 self::TABLE_Category => array($this->recordIds['newCategoryId']),
138 self::TABLE_Content => array($this->recordIds['newContentId']),
139 )
140 );
141 $this->assertAssertionDataSet('createContentNCreateRelation');
142
143 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
144 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
145 $this->assertResponseContentStructureHasRecords(
146 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
147 self::TABLE_Category, 'title', 'Testing #1'
148 );
149 }
150
151 /**
152 * @test
153 * @see DataSet/Assertion/createCategoryRecordAndCreateCategoryRelation.csv
154 */
155 public function createCategoryAndCreateRelation() {
156 parent::createCategoryAndCreateRelation();
157 $this->actionService->publishRecords(
158 array(
159 self::TABLE_Content => array($this->recordIds['newContentId']),
160 self::TABLE_Category => array($this->recordIds['newCategoryId']),
161 )
162 );
163 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
164 $this->assertAssertionDataSet('createCategoryNCreateRelation');
165 }
166
167 /**
168 * @test
169 * @see DataSet/Assertion/modifyCategoryRecordOfCategoryRelation.csv
170 */
171 public function modifyCategoryOfRelation() {
172 parent::modifyCategoryOfRelation();
173 $this->actionService->publishRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
174 $this->assertAssertionDataSet('modifyCategoryOfRelation');
175
176 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
177 $this->assertResponseContentStructureHasRecords(
178 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
179 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
180 );
181 }
182
183 /**
184 * @test
185 * @see DataSet/Assertion/modifyContentRecordOfCategoryRelation.csv
186 */
187 public function modifyContentOfRelation() {
188 parent::modifyContentOfRelation();
189 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
190 $this->assertAssertionDataSet('modifyContentOfRelation');
191
192 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
193 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
194 }
195
196 /**
197 * @test
198 * @see DataSet/Assertion/modifyBothRecordsOfCategoryRelation.csv
199 */
200 public function modifyBothsOfRelation() {
201 parent::modifyBothsOfRelation();
202 $this->actionService->publishRecords(
203 array(
204 self::TABLE_Content => array(self::VALUE_ContentIdFirst),
205 self::TABLE_Category => array(self::VALUE_CategoryIdFirst),
206 )
207 );
208 $this->assertAssertionDataSet('modifyBothsOfRelation');
209
210 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
211 $this->assertResponseContentStructureHasRecords(
212 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
213 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
214 );
215 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
216 }
217
218 /**
219 * @test
220 * @see DataSet/Assertion/deleteContentRecordOfCategoryRelation.csv
221 */
222 public function deleteContentOfRelation() {
223 parent::deleteContentOfRelation();
224 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
225 $this->assertAssertionDataSet('deleteContentOfRelation');
226
227 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
228 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
229 }
230
231 /**
232 * @test
233 * @see DataSet/Assertion/deleteCategoryRecordOfCategoryRelation.csv
234 */
235 public function deleteCategoryOfRelation() {
236 parent::deleteCategoryOfRelation();
237 $this->actionService->publishRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
238 $this->assertAssertionDataSet('deleteCategoryOfRelation');
239
240 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
241 $this->assertResponseContentStructureDoesNotHaveRecords(
242 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
243 self::TABLE_Category, 'title', array('Category A')
244 );
245 }
246
247 /**
248 * @test
249 * @see DataSet/Assertion/copyContentRecordOfCategoryRelation.csv
250 */
251 public function copyContentOfRelation() {
252 parent::copyContentOfRelation();
253 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
254 $this->assertAssertionDataSet('copyContentOfRelation');
255
256 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
257 $this->assertResponseContentStructureHasRecords(
258 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
259 self::TABLE_Category, 'title', array('Category B', 'Category C')
260 );
261 }
262
263 /**
264 * @test
265 * @see DataSet/Assertion/copyCategoryRecordOfCategoryRelation.csv
266 */
267 public function copyCategoryOfRelation() {
268 parent::copyCategoryOfRelation();
269 $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['newCategoryId']);
270 $this->assertAssertionDataSet('copyCategoryOfRelation');
271
272 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
273 $this->assertResponseContentStructureHasRecords(
274 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
275 self::TABLE_Category, 'title', array('Category A', 'Category A (copy 1)')
276 );
277 }
278
279 /**
280 * @test
281 * @see DataSet/Assertion/localizeContentRecordOfCategoryRelation.csv
282 */
283 public function localizeContentOfRelation() {
284 parent::localizeContentOfRelation();
285 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
286 $this->assertAssertionDataSet('localizeContentOfRelation');
287
288 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
289 $this->assertResponseContentStructureHasRecords(
290 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
291 self::TABLE_Category, 'title', array('Category B', 'Category C')
292 );
293 }
294
295 /**
296 * @test
297 * @see DataSet/Assertion/localizeCategoryRecordOfCategoryRelation.csv
298 */
299 public function localizeCategoryOfRelation() {
300 parent::localizeCategoryOfRelation();
301 $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['localizedCategoryId']);
302 $this->assertAssertionDataSet('localizeCategoryOfRelation');
303
304 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
305 $this->assertResponseContentStructureHasRecords(
306 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
307 self::TABLE_Category, 'title', array('[Translate to Dansk:] Category A', 'Category B')
308 );
309 }
310
311 /**
312 * @test
313 * @see DataSet/Assertion/moveContentRecordOfCategoryRelationToDifferentPage.csv
314 */
315 public function moveContentOfRelationToDifferentPage() {
316 parent::moveContentOfRelationToDifferentPage();
317 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
318 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
319
320 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseContent();
321 $this->assertResponseContentStructureHasRecords(
322 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
323 self::TABLE_Category, 'title', array('Category B', 'Category C')
324 );
325 }
326
327 /**
328 * @test
329 * @see DataSet/Assertion/copyPage.csv
330 */
331 public function copyPage() {
332 parent::copyPage();
333 $this->actionService->publishRecords(
334 array(
335 self::TABLE_Page => array($this->recordIds['newPageId']),
336 self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
337 )
338 );
339 $this->assertAssertionDataSet('copyPage');
340
341 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseContent();
342 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Relations');
343 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
344 $this->assertResponseContentStructureHasRecords(
345 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'], 'categories',
346 self::TABLE_Category, 'title', array('Category A', 'Category B')
347 );
348 $this->assertResponseContentStructureHasRecords(
349 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'], 'categories',
350 self::TABLE_Category, 'title', array('Category B', 'Category C')
351 );
352 }
353
354 }