[TASK] Restructure functional frontend tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / FAL / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\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\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/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, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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')->setStrict(TRUE));
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, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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')->setStrict(TRUE));
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, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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')->setStrict(TRUE));
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, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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')->setStrict(TRUE));
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, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->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')->setStrict(TRUE));
143
144 $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
145 $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
146 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
147 $this->assertThat($responseSectionsTarget, $this->getRequestSectionStructureHasRecordConstraint()
148 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
149 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
150 }
151
152 /**
153 * @test
154 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
155 */
156 public function moveContentToDifferentPageAndChangeSorting() {
157 parent::moveContentToDifferentPageAndChangeSorting();
158 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
159
160 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
161 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
162 ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
163 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
164 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
165 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(TRUE));
166 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
167 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
168 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(TRUE));
169 }
170
171 /**
172 * File references
173 */
174
175 /**
176 * @test
177 * @see DataSets/createContentWFileReference.csv
178 */
179 public function createContentWithFileReference() {
180 parent::createContentWithFileReference();
181 $this->assertAssertionDataSet('createContentWFileReference');
182
183 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
184 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
185 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
186 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
187 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
188 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(TRUE));
189 }
190
191 /**
192 * @test
193 * @see DataSets/modifyContentWFileReference.csv
194 */
195 public function modifyContentWithFileReference() {
196 parent::modifyContentWithFileReference();
197 $this->assertAssertionDataSet('modifyContentWFileReference');
198
199 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
200 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
201 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
202 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
203 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
204 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(TRUE));
205 }
206
207 /**
208 * @test
209 * @see DataSets/modifyContentNAddFileReference.csv
210 */
211 public function modifyContentAndAddFileReference() {
212 parent::modifyContentAndAddFileReference();
213 $this->assertAssertionDataSet('modifyContentNAddFileReference');
214
215 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
216 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
217 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
218 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(TRUE));
219 }
220
221 /**
222 * @test
223 * @see DataSets/modifyContentNDeleteFileReference.csv
224 */
225 public function modifyContentAndDeleteFileReference() {
226 parent::modifyContentAndDeleteFileReference();
227 $this->assertAssertionDataSet('modifyContentNDeleteFileReference');
228
229 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
230 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
231 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
232 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(TRUE));
233 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
234 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
235 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
236 }
237
238 /**
239 * @test
240 * @see DataSets/modifyContentNDeleteAllFileReference.csv
241 */
242 public function modifyContentAndDeleteAllFileReference() {
243 parent::modifyContentAndDeleteAllFileReference();
244 $this->assertAssertionDataSet('modifyContentNDeleteAllFileReference');
245
246 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
247 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
248 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
249 ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
250 }
251
252 }