3d0a7d9b344c93bc5b29c8206f78c1af2ed49b44
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Select / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\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\Select\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Select/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 $this->assertResponseContentStructureHasRecords(
219 $responseContent, self::TABLE_Content . ':' . $this->recordIds['copiedContentId'], self::FIELD_ContentElement,
220 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
221 );
222 }
223
224 /**
225 * @test
226 * @see DataSet/copyElementOfRelation.csv
227 */
228 public function copyElementOfRelation() {
229 parent::copyElementOfRelation();
230 $this->assertAssertionDataSet('copyElementOfRelation');
231
232 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
233 $this->assertResponseContentStructureHasRecords(
234 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
235 self::TABLE_Element, 'title', array('Element #1')
236 );
237 // Referenced elements are not updated at the "parent", which is expected and correct
238 $this->assertResponseContentStructureDoesNotHaveRecords(
239 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
240 self::TABLE_Element, 'title', array('Element #1 (copy 1)')
241 );
242 }
243
244 /**
245 * @test
246 * @see DataSet/localizeContentOfRelation.csv
247 */
248 public function localizeContentOfRelation() {
249 parent::localizeContentOfRelation();
250 $this->assertAssertionDataSet('localizeContentOfRelation');
251
252 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
253 $this->assertResponseContentStructureHasRecords(
254 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentElement,
255 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
256 );
257 }
258
259 /**
260 * @test
261 * @see DataSet/localizeElementOfRelation.csv
262 */
263 public function localizeElementOfRelation() {
264 parent::localizeElementOfRelation();
265 $this->assertAssertionDataSet('localizeElementOfRelation');
266
267 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
268 $this->assertResponseContentStructureHasRecords(
269 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentElement,
270 self::TABLE_Element, 'title', array('[Translate to Dansk:] Element #1', 'Element #2')
271 );
272 }
273
274 /**
275 * @test
276 * @see DataSet/moveContentOfRelationToDifferentPage.csv
277 */
278 public function moveContentOfRelationToDifferentPage() {
279 parent::moveContentOfRelationToDifferentPage();
280 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
281
282 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
283 $this->assertResponseContentStructureHasRecords(
284 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentElement,
285 self::TABLE_Element, 'title', array('Element #2', 'Element #3')
286 );
287 }
288
289 }