TYPO3 CMS  TYPO3_7-6
ActionTest.php
Go to the documentation of this file.
1 <?php
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 
21 {
25  protected $assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Group/Modify/DataSet/';
26 
35  public function addElementRelation()
36  {
37  parent::addElementRelation();
38  $this->assertAssertionDataSet('addElementRelation');
39 
40  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
41  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
42  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
43  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
44  }
45 
50  public function deleteElementRelation()
51  {
52  parent::deleteElementRelation();
53  $this->assertAssertionDataSet('deleteElementRelation');
54 
55  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
56  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
57  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
58  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
59  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
60  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
61  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
62  }
63 
68  public function changeElementSorting()
69  {
70  parent::changeElementSorting();
71  $this->assertAssertionDataSet('changeElementSorting');
72 
73  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
74  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
75  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
76  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
77  }
78 
83  public function changeElementRelationSorting()
84  {
85  parent::changeElementRelationSorting();
86  $this->assertAssertionDataSet('changeElementRelationSorting');
87 
88  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
89  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
90  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
91  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
92  }
93 
99  {
100  parent::createContentAndAddElementRelation();
101  $this->assertAssertionDataSet('createContentNAddRelation');
102 
103  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
104  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
105  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
106  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
107  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
108  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
109  }
110 
116  {
117  parent::createContentAndCreateElementRelation();
118  $this->assertAssertionDataSet('createContentNCreateRelation');
119 
120  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
121  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
122  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
123  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
124  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
125  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
126  }
127 
132  public function modifyElementOfRelation()
133  {
134  parent::modifyElementOfRelation();
135  $this->assertAssertionDataSet('modifyElementOfRelation');
136 
137  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
138  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
139  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
140  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
141  }
142 
147  public function modifyContentOfRelation()
148  {
149  parent::modifyContentOfRelation();
150  $this->assertAssertionDataSet('modifyContentOfRelation');
151 
152  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
153  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
154  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
155  }
156 
161  public function modifyBothSidesOfRelation()
162  {
163  parent::modifyBothSidesOfRelation();
164  $this->assertAssertionDataSet('modifyBothSidesOfRelation');
165 
166  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
167  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
168  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
169  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
170  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
171  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
172  }
173 
178  public function deleteContentOfRelation()
179  {
180  parent::deleteContentOfRelation();
181  $this->assertAssertionDataSet('deleteContentOfRelation');
182 
183  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
184  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
185  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
186  }
187 
192  public function deleteElementOfRelation()
193  {
194  parent::deleteElementOfRelation();
195  $this->assertAssertionDataSet('deleteElementOfRelation');
196 
197  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
198  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
199  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
200  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
201  }
202 
207  public function copyContentOfRelation()
208  {
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 
223  public function copyElementOfRelation()
224  {
225  parent::copyElementOfRelation();
226  $this->assertAssertionDataSet('copyElementOfRelation');
227 
228  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
229  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
230  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
231  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
232  // Referenced elements are not updated at the "parent", which is expected and correct
233  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
234  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
235  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
236  }
237 
243  {
244  parent::copyContentToLanguageOfRelation();
245  $this->assertAssertionDataSet('copyContentToLanguageOfRelation');
246 
247  $this->setUpFrontendRootPage(1, [
248  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
249  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
250  ]);
251  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
252  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
253  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['localizedContentId'])->setRecordField(self::FIELD_ContentElement)
254  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
255  }
256 
262  {
263  parent::copyElementToLanguageOfRelation();
264  $this->assertAssertionDataSet('copyElementToLanguageOfRelation');
265 
266  //in this case the translated element is orphaned (no CE with relation to it, and it has no l10n_parent)
267  //so on frontend there is no change.
268  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
269  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
270  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
271  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
272  }
273 
278  public function localizeContentOfRelation()
279  {
280  parent::localizeContentOfRelation();
281  $this->assertAssertionDataSet('localizeContentOfRelation');
282 
283  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
284  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
285  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
286  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
287  }
288 
293  public function localizeElementOfRelation()
294  {
295  parent::localizeElementOfRelation();
296  $this->assertAssertionDataSet('localizeElementOfRelation');
297 
298  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
299  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
300  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
301  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
302  }
303 
309  {
310  parent::moveContentOfRelationToDifferentPage();
311  $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
312 
313  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
314  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
315  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
316  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
317  }
318 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=true, $frontendUserId=0)
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])