[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / Group / Publish / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 require_once dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
18
19 /**
20 * Functional test for the DataHandler
21 */
22 class ActionTest extends \TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\AbstractActionTestCase {
23
24 /**
25 * @var string
26 */
27 protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Group/Publish/DataSet/';
28
29 /**
30 * Relations
31 */
32
33 /**
34 * @test
35 * @see DataSet/addElementRelation.csv
36 */
37 public function addElementRelation() {
38 parent::addElementRelation();
39 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
40 $this->assertAssertionDataSet('addElementRelation');
41
42 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
43 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
44 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
45 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
46 }
47
48 /**
49 * @test
50 * @see DataSet/deleteElementRelation.csv
51 */
52 public function deleteElementRelation() {
53 parent::deleteElementRelation();
54 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
55 $this->assertAssertionDataSet('deleteElementRelation');
56
57 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
58 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
59 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
60 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
61 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
62 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
63 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
64 }
65
66 /**
67 * @test
68 * @see DataSet/changeElementSorting.csv
69 */
70 public function changeElementSorting() {
71 parent::changeElementSorting();
72 $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
73 $this->assertAssertionDataSet('changeElementSorting');
74
75 $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
76 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
77 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
78 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
79 }
80
81 /**
82 * @test
83 * @see DataSet/changeElementRelationSorting.csv
84 */
85 public function changeElementRelationSorting() {
86 parent::changeElementRelationSorting();
87 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
88 $this->assertAssertionDataSet('changeElementRelationSorting');
89
90 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
91 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
92 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
93 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
94 }
95
96 /**
97 * @test
98 * @see DataSet/createContentNAddRelation.csv
99 */
100 public function createContentAndAddElementRelation() {
101 parent::createContentAndAddElementRelation();
102 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
103 $this->assertAssertionDataSet('createContentNAddRelation');
104
105 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
106 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
107 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
108 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
109 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
110 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
111 }
112
113 /**
114 * @test
115 * @see DataSet/createContentNCreateRelation.csv
116 */
117 public function createContentAndCreateElementRelation() {
118 parent::createContentAndCreateElementRelation();
119 $this->actionService->publishRecords(
120 array(
121 self::TABLE_Content => array($this->recordIds['newContentId']),
122 self::TABLE_Element => array($this->recordIds['newElementId']),
123 )
124 );
125 $this->assertAssertionDataSet('createContentNCreateRelation');
126
127 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
128 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
129 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
130 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
131 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
132 ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
133 }
134
135 /**
136 * @test
137 * @see DataSet/modifyElementOfRelation.csv
138 */
139 public function modifyElementOfRelation() {
140 parent::modifyElementOfRelation();
141 $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
142 $this->assertAssertionDataSet('modifyElementOfRelation');
143
144 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
145 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
146 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
147 ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
148 }
149
150 /**
151 * @test
152 * @see DataSet/modifyContentOfRelation.csv
153 */
154 public function modifyContentOfRelation() {
155 parent::modifyContentOfRelation();
156 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
157 $this->assertAssertionDataSet('modifyContentOfRelation');
158
159 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
160 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
161 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
162 }
163
164 /**
165 * @test
166 * @see DataSet/modifyBothSidesOfRelation.csv
167 */
168 public function modifyBothSidesOfRelation() {
169 parent::modifyBothSidesOfRelation();
170 $this->actionService->publishRecords(
171 array(
172 self::TABLE_Content => array(self::VALUE_ContentIdFirst),
173 self::TABLE_Element => array(self::VALUE_ElementIdFirst),
174 )
175 );
176 $this->assertAssertionDataSet('modifyBothSidesOfRelation');
177
178 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
179 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
180 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
181 ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
182 $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
183 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
184 }
185
186 /**
187 * @test
188 * @see DataSet/deleteContentOfRelation.csv
189 */
190 public function deleteContentOfRelation() {
191 parent::deleteContentOfRelation();
192 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
193 $this->assertAssertionDataSet('deleteContentOfRelation');
194
195 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
196 $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
197 ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
198 }
199
200 /**
201 * @test
202 * @see DataSet/deleteElementOfRelation.csv
203 */
204 public function deleteElementOfRelation() {
205 parent::deleteElementOfRelation();
206 $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
207 $this->assertAssertionDataSet('deleteElementOfRelation');
208
209 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
210 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
211 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
212 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
213 }
214
215 /**
216 * @test
217 * @see DataSet/copyContentOfRelation.csv
218 */
219 public function copyContentOfRelation() {
220 parent::copyContentOfRelation();
221 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
222 $this->assertAssertionDataSet('copyContentOfRelation');
223
224 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
225 // Referenced elements are not copied with the "parent", which is expected and correct
226 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
227 ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
228 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
229 }
230
231 /**
232 * @test
233 * @see DataSet/copyElementOfRelation.csv
234 */
235 public function copyElementOfRelation() {
236 parent::copyElementOfRelation();
237 $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['copiedElementId']);
238 $this->assertAssertionDataSet('copyElementOfRelation');
239
240 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
241 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
242 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
243 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
244 // Referenced elements are not updated at the "parent", which is expected and correct
245 $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
246 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
247 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
248 }
249
250 /**
251 * @test
252 * @see DataSet/localizeContentOfRelation.csv
253 */
254 public function localizeContentOfRelation() {
255 parent::localizeContentOfRelation();
256 $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
257 $this->assertAssertionDataSet('localizeContentOfRelation');
258
259 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
260 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
261 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
262 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
263 }
264
265 /**
266 * @test
267 * @see DataSet/localizeElementOfRelation.csv
268 */
269 public function localizeElementOfRelation() {
270 parent::localizeElementOfRelation();
271 $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['localizedElementId']);
272 $this->assertAssertionDataSet('localizeElementOfRelation');
273
274 $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
275 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
276 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
277 ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
278 }
279
280 /**
281 * @test
282 * @see DataSet/moveContentOfRelationToDifferentPage.csv
283 */
284 public function moveContentOfRelationToDifferentPage() {
285 parent::moveContentOfRelationToDifferentPage();
286 $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
287 $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
288
289 $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseSections();
290 $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
291 ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
292 ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
293 }
294
295 }