TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
core/Tests/Functional/DataHandling/Select/Modify/ActionTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify;
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/Select/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  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
214  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
215  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
216  }
217 
222  public function copyElementOfRelation()
223  {
224  parent::copyElementOfRelation();
225  $this->assertAssertionDataSet('copyElementOfRelation');
226 
227  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
228  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
229  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
230  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
231  // Referenced elements are not updated at the "parent", which is expected and correct
232  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
233  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
234  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
235  }
236 
241  public function localizeContentOfRelation()
242  {
243  parent::localizeContentOfRelation();
244  $this->assertAssertionDataSet('localizeContentOfRelation');
245 
246  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
247  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
248  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
249  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
250  }
251 
256  public function localizeElementOfRelation()
257  {
258  parent::localizeElementOfRelation();
259  $this->assertAssertionDataSet('localizeElementOfRelation');
260 
261  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
262  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
263  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
264  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
265  }
266 
272  {
273  parent::moveContentOfRelationToDifferentPage();
274  $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
275 
276  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
277  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
278  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
279  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
280  }
281 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=true, $frontendUserId=0)