[TASK] Restructure functional frontend tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / FAL / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\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\FAL\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/FAL/Modify/DataSet/';
38
39 /**
40 * Content records
41 */
42
43 /**
44 * @test
45 * @see DataSet/Assertion/modifyContentRecord.csv
46 */
47 public function modifyContent() {
48 parent::modifyContent();
49 $this->assertAssertionDataSet('modifyContent');
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'));
54 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
55 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
56 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
57 }
58
59 /**
60 * @test
61 * @see DataSet/Assertion/deleteContentRecord.csv
62 */
63 public function deleteContent() {
64 parent::deleteContent();
65 $this->assertAssertionDataSet('deleteContent');
66
67 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
68 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
69 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
70 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
71 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
72 }
73
74 /**
75 * @test
76 * @see DataSet/Assertion/copyContentRecord.csv
77 */
78 public function copyContent() {
79 parent::copyContent();
80 $this->assertAssertionDataSet('copyContent');
81
82 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
83 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
84 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
85 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
86 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentImage)
87 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
88 }
89
90 /**
91 * @test
92 * @see DataSet/Assertion/localizeContentRecord.csv
93 */
94 public function localizeContent() {
95 parent::localizeContent();
96 $this->assertAssertionDataSet('localizeContent');
97
98 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
99 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
100 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
101
102 // @todo Values in sys_file_reference are not copied during localization...
103 /*
104 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
105 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
106 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
107 */
108 }
109
110 /**
111 * @test
112 * @see DataSet/Assertion/changeContentRecordSorting.csv
113 */
114 public function changeContentSorting() {
115 parent::changeContentSorting();
116 $this->assertAssertionDataSet('changeContentSorting');
117
118 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
119 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
120 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
121 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
122 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
123 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
124 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
125 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
126 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
127 }
128
129 /**
130 * @test
131 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
132 */
133 public function moveContentToDifferentPage() {
134 parent::moveContentToDifferentPage();
135 $this->assertAssertionDataSet('moveContentToDifferentPage');
136
137 $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
138 $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
139 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
140 $this->assertThat($responseSectionsSource, $this->getRequestSectionStructureHasRecordConstraint()
141 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
142 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
143 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
144 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
145 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
146 $this->assertThat($responseSectionsTarget, $this->getRequestSectionStructureHasRecordConstraint()
147 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
148 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
149 }
150
151 /**
152 * @test
153 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
154 */
155 public function moveContentToDifferentPageAndChangeSorting() {
156 parent::moveContentToDifferentPageAndChangeSorting();
157 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
158
159 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
160 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
161 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
162 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
163 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
164 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
165 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
166 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
167 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
168 }
169
170 /**
171 * File references
172 */
173
174 /**
175 * @test
176 * @see DataSets/createContentWFileReference.csv
177 */
178 public function createContentWithFileReference() {
179 parent::createContentWithFileReference();
180 $this->assertAssertionDataSet('createContentWFileReference');
181
182 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
183 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
184 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
185 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
186 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
187 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1'));
188 }
189
190 /**
191 * @test
192 * @see DataSets/modifyContentWFileReference.csv
193 */
194 public function modifyContentWithFileReference() {
195 parent::modifyContentWithFileReference();
196 $this->assertAssertionDataSet('modifyContentWFileReference');
197
198 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
199 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
200 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
201 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
202 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
203 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1'));
204 }
205
206 /**
207 * @test
208 * @see DataSets/modifyContentNAddFileReference.csv
209 */
210 public function modifyContentAndAddFileReference() {
211 parent::modifyContentAndAddFileReference();
212 $this->assertAssertionDataSet('modifyContentNAddFileReference');
213
214 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
215 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
216 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
217 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3'));
218 }
219
220 /**
221 * @test
222 * @see DataSets/modifyContentNDeleteFileReference.csv
223 */
224 public function modifyContentAndDeleteFileReference() {
225 parent::modifyContentAndDeleteFileReference();
226 $this->assertAssertionDataSet('modifyContentNDeleteFileReference');
227
228 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
229 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
230 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
231 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper'));
232 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
233 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
234 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
235 }
236
237 /**
238 * @test
239 * @see DataSets/modifyContentNDeleteAllFileReference.csv
240 */
241 public function modifyContentAndDeleteAllFileReference() {
242 parent::modifyContentAndDeleteAllFileReference();
243 $this->assertAssertionDataSet('modifyContentNDeleteAllFileReference');
244
245 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
246 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
247 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
248 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
249 }
250
251 }