[TASK] Restructure functional frontend tests
[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 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
52 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
53 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
54 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
55 }
56
57 /**
58 * @test
59 * @see DataSet/deleteElementRelation.csv
60 */
61 public function deleteElementRelation() {
62 parent::deleteElementRelation();
63 $this->assertAssertionDataSet('deleteElementRelation');
64
65 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
66 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
67 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
68 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
69 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
70 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
71 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
72 }
73
74 /**
75 * @test
76 * @see DataSet/changeElementSorting.csv
77 */
78 public function changeElementSorting() {
79 parent::changeElementSorting();
80 $this->assertAssertionDataSet('changeElementSorting');
81
82 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
83 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
84 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
85 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
86 }
87
88 /**
89 * @test
90 * @see DataSet/changeElementRelationSorting.csv
91 */
92 public function changeElementRelationSorting() {
93 parent::changeElementRelationSorting();
94 $this->assertAssertionDataSet('changeElementRelationSorting');
95
96 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
97 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
98 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
99 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
100 }
101
102 /**
103 * @test
104 * @see DataSet/createContentNAddRelation.csv
105 */
106 public function createContentAndAddElementRelation() {
107 parent::createContentAndAddElementRelation();
108 $this->assertAssertionDataSet('createContentNAddRelation');
109
110 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
111 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
112 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
113 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
114 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
115 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
116 }
117
118 /**
119 * @test
120 * @see DataSet/createContentNCreateRelation.csv
121 */
122 public function createContentAndCreateElementRelation() {
123 parent::createContentAndCreateElementRelation();
124 $this->assertAssertionDataSet('createContentNCreateRelation');
125
126 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
127 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
128 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
129 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
130 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
131 ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
132 }
133
134 /**
135 * @test
136 * @see DataSet/modifyElementOfRelation.csv
137 */
138 public function modifyElementOfRelation() {
139 parent::modifyElementOfRelation();
140 $this->assertAssertionDataSet('modifyElementOfRelation');
141
142 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
143 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
144 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
145 ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
146 }
147
148 /**
149 * @test
150 * @see DataSet/modifyContentOfRelation.csv
151 */
152 public function modifyContentOfRelation() {
153 parent::modifyContentOfRelation();
154 $this->assertAssertionDataSet('modifyContentOfRelation');
155
156 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
157 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
158 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
159 }
160
161 /**
162 * @test
163 * @see DataSet/modifyBothSidesOfRelation.csv
164 */
165 public function modifyBothSidesOfRelation() {
166 parent::modifyBothSidesOfRelation();
167 $this->assertAssertionDataSet('modifyBothSidesOfRelation');
168
169 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
170 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
171 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
172 ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
173 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
174 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
175 }
176
177 /**
178 * @test
179 * @see DataSet/deleteContentOfRelation.csv
180 */
181 public function deleteContentOfRelation() {
182 parent::deleteContentOfRelation();
183 $this->assertAssertionDataSet('deleteContentOfRelation');
184
185 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
186 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
187 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
188 }
189
190 /**
191 * @test
192 * @see DataSet/deleteElementOfRelation.csv
193 */
194 public function deleteElementOfRelation() {
195 parent::deleteElementOfRelation();
196 $this->assertAssertionDataSet('deleteElementOfRelation');
197
198 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
199 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
200 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
201 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
202 }
203
204 /**
205 * @test
206 * @see DataSet/copyContentOfRelation.csv
207 */
208 public function copyContentOfRelation() {
209 parent::copyContentOfRelation();
210 $this->assertAssertionDataSet('copyContentOfRelation');
211
212 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
213 // Referenced elements are not copied with the "parent", which is expected and correct
214 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
215 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
216 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
217 }
218
219 /**
220 * @test
221 * @see DataSet/copyElementOfRelation.csv
222 */
223 public function copyElementOfRelation() {
224 parent::copyElementOfRelation();
225 $this->assertAssertionDataSet('copyElementOfRelation');
226
227 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
228 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
229 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
230 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
231 // Referenced elements are not updated at the "parent", which is expected and correct
232 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
233 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
234 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
235 }
236
237 /**
238 * @test
239 * @see DataSet/localizeContentOfRelation.csv
240 */
241 public function localizeContentOfRelation() {
242 parent::localizeContentOfRelation();
243 $this->assertAssertionDataSet('localizeContentOfRelation');
244
245 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
246 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
247 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
248 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
249 }
250
251 /**
252 * @test
253 * @see DataSet/localizeElementOfRelation.csv
254 */
255 public function localizeElementOfRelation() {
256 parent::localizeElementOfRelation();
257 $this->assertAssertionDataSet('localizeElementOfRelation');
258
259 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
260 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
261 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
262 ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
263 }
264
265 /**
266 * @test
267 * @see DataSet/moveContentOfRelationToDifferentPage.csv
268 */
269 public function moveContentOfRelationToDifferentPage() {
270 parent::moveContentOfRelationToDifferentPage();
271 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
272
273 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
274 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
275 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
276 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
277 }
278
279 }