‪TYPO3CMS  11.5
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
23 
28 {
32  public function ‪verifyCleanReferenceIndex(): void
33  {
34  // The test verifies the imported data set has a clean reference index by the check in tearDown()
35  self::assertTrue(true);
36  }
37 
42  public function ‪addElementRelation(): void
43  {
44  parent::addElementRelation();
45  $this->assertCSVDataSet(__DIR__ . '/DataSet/addElementRelation.csv');
46 
47  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
48  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
49  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
50  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
51  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
52  }
53 
58  public function ‪deleteElementRelation(): void
59  {
60  parent::deleteElementRelation();
61  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementRelation.csv');
62 
63  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
64  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
65  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
66  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
67  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
68  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
69  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
70  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
71  }
72 
77  public function ‪changeElementSorting(): void
78  {
79  parent::changeElementSorting();
80  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeElementSorting.csv');
81 
82  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
83  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
84  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
85  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
86  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
87  }
88 
93  public function ‪changeElementRelationSorting(): void
94  {
95  parent::changeElementRelationSorting();
96  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeElementRelationSorting.csv');
97 
98  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
99  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
100  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
101  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
102  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
103  }
104 
110  {
111  parent::createContentAndAddElementRelation();
112  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNAddRelation.csv');
113 
114  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
115  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
116  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
117  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
118  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
119  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
120  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
121  }
122 
128  {
129  parent::createContentAndCreateElementRelation();
130  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNCreateRelation.csv');
131 
132  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
133  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
134  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
135  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
136  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
137  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
138  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
139  }
140 
145  public function ‪modifyElementOfRelation(): void
146  {
147  parent::modifyElementOfRelation();
148  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyElementOfRelation.csv');
149 
150  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
151  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
152  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
153  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
154  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
155  }
156 
161  public function ‪modifyContentOfRelation(): void
162  {
163  parent::modifyContentOfRelation();
164  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentOfRelation.csv');
165 
166  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
167  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
168  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
169  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
170  }
171 
176  public function ‪modifyBothSidesOfRelation(): void
177  {
178  parent::modifyBothSidesOfRelation();
179  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyBothSidesOfRelation.csv');
180 
181  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
182  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
183  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
184  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
185  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
186  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
187  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
188  }
189 
194  public function ‪deleteContentOfRelation(): void
195  {
196  parent::deleteContentOfRelation();
197  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContentOfRelation.csv');
198 
199  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
200  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
201  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
202  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
203  }
204 
209  public function ‪deleteElementOfRelation(): void
210  {
211  parent::deleteElementOfRelation();
212  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementOfRelation.csv');
213 
214  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
215  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
216  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
217  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
218  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
219  }
220 
225  public function ‪copyContentOfRelation(): void
226  {
227  parent::copyContentOfRelation();
228  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentOfRelation.csv');
229 
230  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
231  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
232  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
233  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
234  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
235  }
236 
241  public function ‪copyElementOfRelation(): void
242  {
243  parent::copyElementOfRelation();
244  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyElementOfRelation.csv');
245 
246  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
247  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
248  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
249  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
250  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
251  // Referenced elements are not updated at the "parent", which is expected and correct
252  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
253  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
254  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
255  }
256 
261  public function ‪copyContentToLanguageOfRelation(): void
262  {
263  parent::copyContentToLanguageOfRelation();
264  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentToLanguageOfRelation.csv');
265 
266  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
267  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
268  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
269  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
270  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
271  }
272 
277  public function ‪copyElementToLanguageOfRelation(): void
278  {
279  parent::copyElementToLanguageOfRelation();
280  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyElementToLanguageOfRelation.csv');
281 
282  //in this case the translated element is orphaned (no CE with relation to it, and it has no l10n_parent)
283  //so on frontend there is no change.
284  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
285  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
286  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
287  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
288  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
289  }
290 
295  public function ‪localizeContentOfRelation(): void
296  {
297  parent::localizeContentOfRelation();
298  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
299 
300  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
301  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
302  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
303  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
304  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
305  }
306 
311  public function ‪localizeElementOfRelation(): void
312  {
313  // Create translated page first
314  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
315  parent::localizeElementOfRelation();
316  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeElementOfRelation.csv');
317 
318  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
319  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
320  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
321  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
322  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
323  }
324 
329  {
330  parent::localizeContentOfRelationWithLocalizeReferencesAtParentLocalization();
331  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationWLocalizeReferencesAtParentLocalization.csv');
332  }
333 
339  {
340  parent::moveContentOfRelationToDifferentPage();
341  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
342 
343  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
344  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
345  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
346  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
347  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
348  }
349 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:311
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:93
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:77
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyElementToLanguageOfRelation
‪copyElementToLanguageOfRelation()
Definition: ActionTest.php:277
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:194
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:241
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:145
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:295
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:161
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:338
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:225
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest
Definition: ActionTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: ActionTest.php:328
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:58
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:176
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: ActionTest.php:261
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:209
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:109
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify
Definition: ActionTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Select\Modify\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:127