‪TYPO3CMS  10.4
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
20 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
21 
26 {
30  protected ‪$assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Select/Modify/DataSet/';
31 
35  public function ‪verifyCleanReferenceIndex()
36  {
37  // The test verifies the imported data set has a clean reference index by the check in tearDown()
38  self::assertTrue(true);
39  }
40 
45  public function ‪addElementRelation()
46  {
47  parent::addElementRelation();
48  $this->‪assertAssertionDataSet('addElementRelation');
49 
50  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
51  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
52  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
53  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
54  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
55  }
56 
61  public function ‪deleteElementRelation()
62  {
63  parent::deleteElementRelation();
64  $this->‪assertAssertionDataSet('deleteElementRelation');
65 
66  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
67  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
68  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
69  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
70  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
71  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
72  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
73  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
74  }
75 
80  public function ‪changeElementSorting()
81  {
82  parent::changeElementSorting();
83  $this->‪assertAssertionDataSet('changeElementSorting');
84 
85  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
86  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
87  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
88  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
89  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
90  }
91 
96  public function ‪changeElementRelationSorting()
97  {
98  parent::changeElementRelationSorting();
99  $this->‪assertAssertionDataSet('changeElementRelationSorting');
100 
101  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
102  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
103  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
104  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
105  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
106  }
107 
112  public function ‪createContentAndAddElementRelation()
113  {
114  parent::createContentAndAddElementRelation();
115  $this->‪assertAssertionDataSet('createContentNAddRelation');
116 
117  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
118  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
119  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
120  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
121  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
122  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
123  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
124  }
125 
131  {
132  parent::createContentAndCreateElementRelation();
133  $this->‪assertAssertionDataSet('createContentNCreateRelation');
134 
135  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
136  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
137  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
138  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
139  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
140  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
141  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
142  }
143 
148  public function ‪modifyElementOfRelation()
149  {
150  parent::modifyElementOfRelation();
151  $this->‪assertAssertionDataSet('modifyElementOfRelation');
152 
153  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
154  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
155  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
156  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
157  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
158  }
159 
164  public function ‪modifyContentOfRelation()
165  {
166  parent::modifyContentOfRelation();
167  $this->‪assertAssertionDataSet('modifyContentOfRelation');
168 
169  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
170  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
171  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
172  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
173  }
174 
179  public function ‪modifyBothSidesOfRelation()
180  {
181  parent::modifyBothSidesOfRelation();
182  $this->‪assertAssertionDataSet('modifyBothSidesOfRelation');
183 
184  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
185  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
186  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
187  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
188  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
189  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
190  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
191  }
192 
197  public function ‪deleteContentOfRelation()
198  {
199  parent::deleteContentOfRelation();
200  $this->‪assertAssertionDataSet('deleteContentOfRelation');
201 
202  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
203  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
204  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
205  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
206  }
207 
212  public function ‪deleteElementOfRelation()
213  {
214  parent::deleteElementOfRelation();
215  $this->‪assertAssertionDataSet('deleteElementOfRelation');
216 
217  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
218  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
219  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
220  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
221  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
222  }
223 
228  public function ‪copyContentOfRelation()
229  {
230  parent::copyContentOfRelation();
231  $this->‪assertAssertionDataSet('copyContentOfRelation');
232 
233  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
234  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
235  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
236  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
237  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
238  }
239 
244  public function ‪copyElementOfRelation()
245  {
246  parent::copyElementOfRelation();
247  $this->‪assertAssertionDataSet('copyElementOfRelation');
248 
249  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
250  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
251  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
252  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
253  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
254  // Referenced elements are not updated at the "parent", which is expected and correct
255  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
256  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
257  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
258  }
259 
264  public function ‪copyContentToLanguageOfRelation()
265  {
266  parent::copyContentToLanguageOfRelation();
267  $this->‪assertAssertionDataSet('copyContentToLanguageOfRelation');
268 
269  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
270  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
271  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
272  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
273  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
274  }
275 
280  public function ‪copyElementToLanguageOfRelation()
281  {
282  parent::copyElementToLanguageOfRelation();
283  $this->‪assertAssertionDataSet('copyElementToLanguageOfRelation');
284 
285  //in this case the translated element is orphaned (no CE with relation to it, and it has no l10n_parent)
286  //so on frontend there is no change.
287  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
288  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
289  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
290  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
291  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
292  }
293 
298  public function ‪localizeContentOfRelation()
299  {
300  parent::localizeContentOfRelation();
301  $this->‪assertAssertionDataSet('localizeContentOfRelation');
302 
303  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
304  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
305  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
306  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
307  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
308  }
309 
314  public function ‪localizeElementOfRelation()
315  {
316  // Create translated page first
317  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
318  parent::localizeElementOfRelation();
319  $this->‪assertAssertionDataSet('localizeElementOfRelation');
320 
321  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
322  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
323  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
324  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
325  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
326  }
327 
333  {
334  parent::moveContentOfRelationToDifferentPage();
335  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
336 
337  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
338  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
339  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
340  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
341  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
342  }
343 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:313
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:95
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:79
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyElementToLanguageOfRelation
‪copyElementToLanguageOfRelation()
Definition: ActionTest.php:279
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:196
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:243
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:147
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:297
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:163
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:331
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:227
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:60
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\assertAssertionDataSet
‪assertAssertionDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:208
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:178
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: ActionTest.php:263
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:211
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:297
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:111
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify
Definition: ActionTest.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:129