f561acaf925e180a5d81cd224efa6acddf41237d
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Regular / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\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\Regular\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/';
38
39 /**
40 * Content records
41 */
42
43 /**
44 * @test
45 * @see DataSet/Assertion/createContentRecords.csv
46 */
47 public function createContents() {
48 parent::createContents();
49 $this->assertAssertionDataSet('createContents');
50
51 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
52 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
53 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
54 }
55
56 /**
57 * @test
58 * @see DataSet/Assertion/modifyContentRecord.csv
59 */
60 public function modifyContent() {
61 parent::modifyContent();
62 $this->assertAssertionDataSet('modifyContent');
63
64 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
65 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
66 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
67 }
68
69 /**
70 * @test
71 * @see DataSet/Assertion/deleteContentRecord.csv
72 */
73 public function deleteContent() {
74 parent::deleteContent();
75 $this->assertAssertionDataSet('deleteContent');
76
77 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
78 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
79 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
80 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
81 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
82 }
83
84 /**
85 * @test
86 * @see DataSet/Assertion/copyContentRecord.csv
87 */
88 public function copyContent() {
89 parent::copyContent();
90 $this->assertAssertionDataSet('copyContent');
91
92 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
93 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
94 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
95 }
96
97 /**
98 * @test
99 * @see DataSet/Assertion/copyContentRecord.csv
100 */
101 public function copyPasteContent() {
102 parent::copyPasteContent();
103 $this->assertAssertionDataSet('copyPasteContent');
104
105 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
106 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
107 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
108 }
109
110 /**
111 * @test
112 * @see DataSet/Assertion/localizeContentRecord.csv
113 */
114 public function localizeContent() {
115 parent::localizeContent();
116 $this->assertAssertionDataSet('localizeContent');
117
118 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
119 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
120 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
121 }
122
123 /**
124 * @test
125 * @see DataSet/Assertion/changeContentRecordSorting.csv
126 */
127 public function changeContentSorting() {
128 parent::changeContentSorting();
129 $this->assertAssertionDataSet('changeContentSorting');
130
131 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
132 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
133 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
134 }
135
136 /**
137 * @test
138 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
139 */
140 public function moveContentToDifferentPage() {
141 parent::moveContentToDifferentPage();
142 $this->assertAssertionDataSet('moveContentToDifferentPage');
143
144 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
145 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
146 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
147 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
148 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
149 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
150 }
151
152 /**
153 * @test
154 * @see DataSet/movePasteContentToDifferentPage.csv
155 */
156 public function movePasteContentToDifferentPage() {
157 parent::movePasteContentToDifferentPage();
158 $this->assertAssertionDataSet('movePasteContentToDifferentPage');
159
160 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
161 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
162 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
163 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
164 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
165 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
166 }
167
168 /**
169 * @test
170 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
171 */
172 public function moveContentToDifferentPageAndChangeSorting() {
173 parent::moveContentToDifferentPageAndChangeSorting();
174 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
175
176 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
177 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
178 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
179 }
180
181 /**
182 * Page records
183 */
184
185 /**
186 * @test
187 * @see DataSet/Assertion/createPageRecord.csv
188 */
189 public function createPage() {
190 parent::createPage();
191 $this->assertAssertionDataSet('createPage');
192
193 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
194 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
195 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
196 }
197
198 /**
199 * @test
200 * @see DataSet/Assertion/modifyPageRecord.csv
201 */
202 public function modifyPage() {
203 parent::modifyPage();
204 $this->assertAssertionDataSet('modifyPage');
205
206 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
207 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
208 ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
209 }
210
211 /**
212 * @test
213 * @see DataSet/Assertion/deletePageRecord.csv
214 */
215 public function deletePage() {
216 parent::deletePage();
217 $this->assertAssertionDataSet('deletePage');
218
219 $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, FALSE);
220 $this->assertContains('PageNotFoundException', $response->getError());
221 }
222
223 /**
224 * @test
225 * @see DataSet/Assertion/copyPageRecord.csv
226 */
227 public function copyPage() {
228 parent::copyPage();
229 $this->assertAssertionDataSet('copyPage');
230
231 $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
232 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
233 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
234 }
235
236 /**
237 * @test
238 * @see DataSet/Assertion/localizePageRecord.csv
239 */
240 public function localizePage() {
241 parent::localizePage();
242 $this->assertAssertionDataSet('localizePage');
243
244 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
245 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
246 ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
247 }
248
249 /**
250 * @test
251 * @see DataSet/Assertion/changePageRecordSorting.csv
252 */
253 public function changePageSorting() {
254 parent::changePageSorting();
255 $this->assertAssertionDataSet('changePageSorting');
256
257 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
258 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
259 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
260 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
261 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
262 }
263
264 /**
265 * @test
266 * @see DataSet/Assertion/movePageRecordToDifferentPage.csv
267 */
268 public function movePageToDifferentPage() {
269 parent::movePageToDifferentPage();
270 $this->assertAssertionDataSet('movePageToDifferentPage');
271
272 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
273 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
274 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
275 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
276 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
277 }
278
279 /**
280 * @test
281 * @see DataSet/Assertion/movePageRecordToDifferentPageAndChangeSorting.csv
282 */
283 public function movePageToDifferentPageAndChangeSorting() {
284 parent::movePageToDifferentPageAndChangeSorting();
285 $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
286
287 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
288 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
289 ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
290 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
291 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
292 }
293
294 }