[BUGFIX] Invalid relations of MM records in workspaces
[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 $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->publishWorkspace(self::VALUE_WorkspaceId);
136 $this->assertAssertionDataSet('createContentNCreateRelation');
137
138 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
139 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
140 $this->assertResponseContentStructureHasRecords(
141 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
142 self::TABLE_Category, 'title', 'Testing #1'
143 );
144 }
145
146 /**
147 * @test
148 * @see DataSet/Assertion/createCategoryRecordAndCreateCategoryRelation.csv
149 */
150 public function createCategoryAndCreateRelation() {
151 parent::createCategoryAndCreateRelation();
152 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
153 $this->assertAssertionDataSet('createCategoryNCreateRelation');
154 }
155
156 /**
157 * @test
158 * @see DataSet/Assertion/modifyCategoryRecordOfCategoryRelation.csv
159 */
160 public function modifyCategoryOfRelation() {
161 parent::modifyCategoryOfRelation();
162 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
163 $this->assertAssertionDataSet('modifyCategoryOfRelation');
164
165 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->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->actionService->publishWorkspace(self::VALUE_WorkspaceId);
179 $this->assertAssertionDataSet('modifyContentOfRelation');
180
181 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
182 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
183 }
184
185 /**
186 * @test
187 * @see DataSet/Assertion/modifyBothRecordsOfCategoryRelation.csv
188 */
189 public function modifyBothsOfRelation() {
190 parent::modifyBothsOfRelation();
191 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
192 $this->assertAssertionDataSet('modifyBothsOfRelation');
193
194 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
195 $this->assertResponseContentStructureHasRecords(
196 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
197 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
198 );
199 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
200 }
201
202 /**
203 * @test
204 * @see DataSet/Assertion/deleteContentRecordOfCategoryRelation.csv
205 */
206 public function deleteContentOfRelation() {
207 parent::deleteContentOfRelation();
208 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
209 $this->assertAssertionDataSet('deleteContentOfRelation');
210
211 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
212 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
213 }
214
215 /**
216 * @test
217 * @see DataSet/Assertion/deleteCategoryRecordOfCategoryRelation.csv
218 */
219 public function deleteCategoryOfRelation() {
220 parent::deleteCategoryOfRelation();
221 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
222 $this->assertAssertionDataSet('deleteCategoryOfRelation');
223
224 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
225 $this->assertResponseContentStructureDoesNotHaveRecords(
226 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
227 self::TABLE_Category, 'title', array('Category A')
228 );
229 }
230
231 /**
232 * @test
233 * @see DataSet/Assertion/copyContentRecordOfCategoryRelation.csv
234 */
235 public function copyContentOfRelation() {
236 parent::copyContentOfRelation();
237 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
238 $this->assertAssertionDataSet('copyContentOfRelation');
239
240 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
241 $this->assertResponseContentStructureHasRecords(
242 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
243 self::TABLE_Category, 'title', array('Category B', 'Category C')
244 );
245 }
246
247 /**
248 * @test
249 * @see DataSet/Assertion/copyCategoryRecordOfCategoryRelation.csv
250 */
251 public function copyCategoryOfRelation() {
252 parent::copyCategoryOfRelation();
253 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
254 $this->assertAssertionDataSet('copyCategoryOfRelation');
255
256 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseContent();
257 $this->assertResponseContentStructureHasRecords(
258 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
259 self::TABLE_Category, 'title', array('Category A', 'Category A (copy 1)')
260 );
261 }
262
263 /**
264 * @test
265 * @see DataSet/Assertion/localizeContentRecordOfCategoryRelation.csv
266 */
267 public function localizeContentOfRelation() {
268 parent::localizeContentOfRelation();
269 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
270 $this->assertAssertionDataSet('localizeContentOfRelation');
271
272 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->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->actionService->publishWorkspace(self::VALUE_WorkspaceId);
286 $this->assertAssertionDataSet('localizeCategoryOfRelation');
287
288 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
289 $this->assertResponseContentStructureHasRecords(
290 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
291 self::TABLE_Category, 'title', array('[Translate to Dansk:] Category A', 'Category B')
292 );
293 }
294
295 /**
296 * @test
297 * @see DataSet/Assertion/moveContentRecordOfCategoryRelationToDifferentPage.csv
298 */
299 public function moveContentOfRelationToDifferentPage() {
300 parent::moveContentOfRelationToDifferentPage();
301 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
302 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
303
304 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseContent();
305 $this->assertResponseContentStructureHasRecords(
306 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
307 self::TABLE_Category, 'title', array('Category B', 'Category C')
308 );
309 }
310
311 /**
312 * @test
313 * @see DataSet/Assertion/copyPage.csv
314 */
315 public function copyPage() {
316 parent::copyPage();
317 $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
318 $this->assertAssertionDataSet('copyPage');
319
320 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseContent();
321 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Relations');
322 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
323 $this->assertResponseContentStructureHasRecords(
324 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'], 'categories',
325 self::TABLE_Category, 'title', array('Category A', 'Category B')
326 );
327 $this->assertResponseContentStructureHasRecords(
328 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'], 'categories',
329 self::TABLE_Category, 'title', array('Category B', 'Category C')
330 );
331 }
332
333 }