[BUGFIX] Invalid relations of MM records in workspaces
[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 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
117 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Category, 'title', 'Testing #1');
118 $this->assertResponseContentStructureHasRecords(
119 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
120 self::TABLE_Category, 'title', 'Testing #1'
121 );
122 }
123
124 /**
125 * @test
126 * @see DataSet/Assertion/createContentRecordAndCreateCategoryRelation.csv
127 */
128 public function createContentAndCreateRelation() {
129 parent::createContentAndCreateRelation();
130 $this->assertAssertionDataSet('createContentNCreateRelation');
131
132 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
133 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
134 $this->assertResponseContentStructureHasRecords(
135 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
136 self::TABLE_Category, 'title', 'Testing #1'
137 );
138 }
139
140 /**
141 * @test
142 * @see DataSet/Assertion/createCategoryRecordAndCreateCategoryRelation.csv
143 */
144 public function createCategoryAndCreateRelation() {
145 parent::createCategoryAndCreateRelation();
146 $this->assertAssertionDataSet('createCategoryNCreateRelation');
147 }
148
149 /**
150 * @test
151 * @see DataSet/Assertion/modifyCategoryRecordOfCategoryRelation.csv
152 */
153 public function modifyCategoryOfRelation() {
154 parent::modifyCategoryOfRelation();
155 $this->assertAssertionDataSet('modifyCategoryOfRelation');
156
157 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
158 $this->assertResponseContentStructureHasRecords(
159 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
160 self::TABLE_Category, 'title', array('Testing #1', 'Category B')
161 );
162 }
163
164 /**
165 * @test
166 * @see DataSet/Assertion/modifyContentRecordOfCategoryRelation.csv
167 */
168 public function modifyContentOfRelation() {
169 parent::modifyContentOfRelation();
170 $this->assertAssertionDataSet('modifyContentOfRelation');
171
172 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
173 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
174 }
175
176 /**
177 * @test
178 * @see DataSet/Assertion/modifyBothRecordsOfCategoryRelation.csv
179 */
180 public function modifyBothsOfRelation() {
181 parent::modifyBothsOfRelation();
182 $this->assertAssertionDataSet('modifyBothsOfRelation');
183
184 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
190 }
191
192 /**
193 * @test
194 * @see DataSet/Assertion/deleteContentRecordOfCategoryRelation.csv
195 */
196 public function deleteContentOfRelation() {
197 parent::deleteContentOfRelation();
198 $this->assertAssertionDataSet('deleteContentOfRelation');
199
200 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
201 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
202 }
203
204 /**
205 * @test
206 * @see DataSet/Assertion/deleteCategoryRecordOfCategoryRelation.csv
207 */
208 public function deleteCategoryOfRelation() {
209 parent::deleteCategoryOfRelation();
210 $this->assertAssertionDataSet('deleteCategoryOfRelation');
211
212 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
213 $this->assertResponseContentStructureDoesNotHaveRecords(
214 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
215 self::TABLE_Category, 'title', array('Category A')
216 );
217 }
218
219 /**
220 * @test
221 * @see DataSet/Assertion/copyContentRecordOfCategoryRelation.csv
222 */
223 public function copyContentOfRelation() {
224 parent::copyContentOfRelation();
225 $this->assertAssertionDataSet('copyContentOfRelation');
226
227 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
228 $this->assertResponseContentStructureHasRecords(
229 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], 'categories',
230 self::TABLE_Category, 'title', array('Category B', 'Category C')
231 );
232 }
233
234 /**
235 * @test
236 * @see DataSet/Assertion/copyCategoryRecordOfCategoryRelation.csv
237 */
238 public function copyCategoryOfRelation() {
239 parent::copyCategoryOfRelation();
240 $this->assertAssertionDataSet('copyCategoryOfRelation');
241
242 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
243 $this->assertResponseContentStructureHasRecords(
244 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'categories',
245 self::TABLE_Category, 'title', array('Category A', 'Category A (copy 1)')
246 );
247 }
248
249 /**
250 * @test
251 * @see DataSet/Assertion/localizeContentRecordOfCategoryRelation.csv
252 */
253 public function localizeContentOfRelation() {
254 parent::localizeContentOfRelation();
255 $this->assertAssertionDataSet('localizeContentOfRelation');
256
257 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
258 $this->assertResponseContentStructureHasRecords(
259 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'categories',
260 self::TABLE_Category, 'title', array('Category B', 'Category C')
261 );
262 }
263
264 /**
265 * @test
266 * @see DataSet/Assertion/localizeCategoryRecordOfCategoryRelation.csv
267 */
268 public function localizeCategoryOfRelation() {
269 parent::localizeCategoryOfRelation();
270 $this->assertAssertionDataSet('localizeCategoryOfRelation');
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_ContentIdFirst, 'categories',
275 self::TABLE_Category, 'title', array('[Translate to Dansk:] Category A', 'Category B')
276 );
277 }
278
279 /**
280 * @test
281 * @see DataSet/Assertion/moveContentRecordOfCategoryRelationToDifferentPage.csv
282 */
283 public function moveContentOfRelationToDifferentPage() {
284 parent::moveContentOfRelationToDifferentPage();
285 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
286
287 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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/copyPage.csv
297 */
298 public function copyPage() {
299 parent::copyPage();
300 $this->assertAssertionDataSet('copyPage');
301
302 $responseContent = $this->getFrontendResponse($this->recordIds['newPageId'], 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
303 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Relations');
304 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
305 $this->assertResponseContentStructureHasRecords(
306 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'], 'categories',
307 self::TABLE_Category, 'title', array('Category A', 'Category B')
308 );
309 $this->assertResponseContentStructureHasRecords(
310 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'], 'categories',
311 self::TABLE_Category, 'title', array('Category B', 'Category C')
312 );
313 }
314
315 }