1772123ee645c8e73199fb473f9827bf45c7c7df
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Group / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\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\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Group/Modify/DataSet/';
38
39 /**
40 * Relations
41 */
42
43 /**
44 * @test
45 * @see DataSet/addElementRelation.csv
46 */
47 public function addElementRelation() {
48 parent::addElementRelation();
49 $this->assertAssertionDataSet('addElementRelation');
50
51 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
52 $this->assertResponseContentStructureHasRecords(
53 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
54 self::TABLE_Element, 'title', array('Element #1', 'Element #2', 'Element #3')
55 );
56 }
57
58 /**
59 * @test
60 * @see DataSet/deleteElementRelation.csv
61 */
62 public function deleteElementRelation() {
63 parent::deleteElementRelation();
64 $this->assertAssertionDataSet('deleteElementRelation');
65
66 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
67 $this->assertResponseContentStructureHasRecords(
68 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
69 self::TABLE_Element, 'title', array('Element #1')
70 );
71 $this->assertResponseContentStructureDoesNotHaveRecords(
72 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
73 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
74 );
75 }
76
77 /**
78 * @test
79 * @see DataSet/changeElementSorting.csv
80 */
81 public function changeElementSorting() {
82 parent::changeElementSorting();
83 $this->assertAssertionDataSet('changeElementSorting');
84
85 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
86 $this->assertResponseContentStructureHasRecords(
87 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
88 self::TABLE_Element, 'title', array('Element #1', 'Element #2')
89 );
90 }
91
92 /**
93 * @test
94 * @see DataSet/changeElementRelationSorting.csv
95 */
96 public function changeElementRelationSorting() {
97 parent::changeElementRelationSorting();
98 $this->assertAssertionDataSet('changeElementRelationSorting');
99
100 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
101 $this->assertResponseContentStructureHasRecords(
102 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
103 self::TABLE_Element, 'title', array('Element #1', 'Element #2')
104 );
105 }
106
107 /**
108 * @test
109 * @see DataSet/createContentNAddRelation.csv
110 */
111 public function createContentAndAddElementRelation() {
112 parent::createContentAndAddElementRelation();
113 $this->assertAssertionDataSet('createContentNAddRelation');
114
115 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
116 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
117 $this->assertResponseContentStructureHasRecords(
118 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentElement,
119 self::TABLE_Element, 'title', 'Element #1'
120 );
121 }
122
123 /**
124 * @test
125 * @see DataSet/createContentNCreateRelation.csv
126 */
127 public function createContentAndCreateElementRelation() {
128 parent::createContentAndCreateElementRelation();
129 $this->assertAssertionDataSet('createContentNCreateRelation');
130
131 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
132 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
133 $this->assertResponseContentStructureHasRecords(
134 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentElement,
135 self::TABLE_Element, 'title', 'Testing #1'
136 );
137 }
138
139 /**
140 * @test
141 * @see DataSet/modifyElementOfRelation.csv
142 */
143 public function modifyElementOfRelation() {
144 parent::modifyElementOfRelation();
145 $this->assertAssertionDataSet('modifyElementOfRelation');
146
147 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
148 $this->assertResponseContentStructureHasRecords(
149 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
150 self::TABLE_Element, 'title', array('Testing #1', 'Element #2')
151 );
152 }
153
154 /**
155 * @test
156 * @see DataSet/modifyContentOfRelation.csv
157 */
158 public function modifyContentOfRelation() {
159 parent::modifyContentOfRelation();
160 $this->assertAssertionDataSet('modifyContentOfRelation');
161
162 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
163 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
164 }
165
166 /**
167 * @test
168 * @see DataSet/modifyBothSidesOfRelation.csv
169 */
170 public function modifyBothSidesOfRelation() {
171 parent::modifyBothSidesOfRelation();
172 $this->assertAssertionDataSet('modifyBothSidesOfRelation');
173
174 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
175 $this->assertResponseContentStructureHasRecords(
176 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
177 self::TABLE_Element, 'title', array('Testing #1', 'Element #2')
178 );
179 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
180 }
181
182 /**
183 * @test
184 * @see DataSet/deleteContentOfRelation.csv
185 */
186 public function deleteContentOfRelation() {
187 parent::deleteContentOfRelation();
188 $this->assertAssertionDataSet('deleteContentOfRelation');
189
190 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
191 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
192 }
193
194 /**
195 * @test
196 * @see DataSet/deleteElementOfRelation.csv
197 */
198 public function deleteElementOfRelation() {
199 parent::deleteElementOfRelation();
200 $this->assertAssertionDataSet('deleteElementOfRelation');
201
202 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
203 $this->assertResponseContentStructureDoesNotHaveRecords(
204 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
205 self::TABLE_Element, 'title', array('Element #1')
206 );
207 }
208
209 /**
210 * @test
211 * @see DataSet/copyContentOfRelation.csv
212 */
213 public function copyContentOfRelation() {
214 parent::copyContentOfRelation();
215 $this->assertAssertionDataSet('copyContentOfRelation');
216
217 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
218 // Referenced elements are not copied with the "parent", which is expected and correct
219 $this->assertResponseContentStructureHasRecords(
220 $responseContent, self::TABLE_Content . ':' . $this->recordIds['copiedContentId'], self::FIELD_ContentElement,
221 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
222 );
223 }
224
225 /**
226 * @test
227 * @see DataSet/copyElementOfRelation.csv
228 */
229 public function copyElementOfRelation() {
230 parent::copyElementOfRelation();
231 $this->assertAssertionDataSet('copyElementOfRelation');
232
233 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
234 $this->assertResponseContentStructureHasRecords(
235 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
236 self::TABLE_Element, 'title', array('Element #1')
237 );
238 // Referenced elements are not updated at the "parent", which is expected and correct
239 $this->assertResponseContentStructureDoesNotHaveRecords(
240 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
241 self::TABLE_Element, 'title', array('Element #1 (copy 1)')
242 );
243 }
244
245 /**
246 * @test
247 * @see DataSet/localizeContentOfRelation.csv
248 */
249 public function localizeContentOfRelation() {
250 parent::localizeContentOfRelation();
251 $this->assertAssertionDataSet('localizeContentOfRelation');
252
253 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
254 $this->assertResponseContentStructureHasRecords(
255 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentElement,
256 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
257 );
258 }
259
260 /**
261 * @test
262 * @see DataSet/localizeElementOfRelation.csv
263 */
264 public function localizeElementOfRelation() {
265 parent::localizeElementOfRelation();
266 $this->assertAssertionDataSet('localizeElementOfRelation');
267
268 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
269 $this->assertResponseContentStructureHasRecords(
270 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
271 self::TABLE_Element, 'title', array('[Translate to Dansk:] Element #1', 'Element #2')
272 );
273 }
274
275 /**
276 * @test
277 * @see DataSet/moveContentOfRelationToDifferentPage.csv
278 */
279 public function moveContentOfRelationToDifferentPage() {
280 parent::moveContentOfRelationToDifferentPage();
281 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
282
283 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
284 $this->assertResponseContentStructureHasRecords(
285 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentElement,
286 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
287 );
288 }
289
290 }