‪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 
41  public function ‪addElementRelation(): void
42  {
43  parent::addElementRelation();
44  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
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 
57  public function ‪deleteElementRelation(): void
58  {
59  parent::deleteElementRelation();
60  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
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 
76  public function ‪changeElementSorting(): void
77  {
78  parent::changeElementSorting();
79  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
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 
92  public function ‪changeElementRelationSorting(): void
93  {
94  parent::changeElementRelationSorting();
95  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
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 
109  {
110  parent::createContentAndAddElementRelation();
111  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
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 
127  {
128  parent::createContentAndCreateElementRelation();
129  $this->actionService->publishRecords([
130  self::TABLE_Content => [$this->recordIds['newContentId']],
131  self::TABLE_Element => [$this->recordIds['newElementId']],
132  ]);
133  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNCreateRelation.csv');
134 
135  $response = $this->executeFrontendSubRequest((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 
147  public function ‪modifyElementOfRelation(): void
148  {
149  parent::modifyElementOfRelation();
150  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
151  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyElementOfRelation.csv');
152 
153  $response = $this->executeFrontendSubRequest((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 
163  public function ‪modifyContentOfRelation(): void
164  {
165  parent::modifyContentOfRelation();
166  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
167  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentOfRelation.csv');
168 
169  $response = $this->executeFrontendSubRequest((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 
178  public function ‪modifyBothSidesOfRelation(): void
179  {
180  parent::modifyBothSidesOfRelation();
181  $this->actionService->publishRecords([
182  self::TABLE_Content => [self::VALUE_ContentIdFirst],
183  self::TABLE_Element => [self::VALUE_ElementIdFirst],
184  ]);
185  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyBothSidesOfRelation.csv');
186 
187  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
188  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
189  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
190  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
191  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
192  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
193  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
194  }
195 
199  public function ‪deleteContentOfRelation(): void
200  {
201  parent::deleteContentOfRelation();
202  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
203  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContentOfRelation.csv');
204 
205  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
206  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
207  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
208  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
209  }
210 
214  public function ‪deleteElementOfRelation(): void
215  {
216  parent::deleteElementOfRelation();
217  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
218  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementOfRelation.csv');
219 
220  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
221  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
222  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
223  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
224  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
225  }
226 
230  public function ‪copyContentOfRelation(): void
231  {
232  parent::copyContentOfRelation();
233  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
234  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentOfRelation.csv');
235 
236  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
237  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
238  // Referenced elements are not copied with the "parent", which is expected and correct
239  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
240  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
241  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
242  }
243 
247  public function ‪copyElementOfRelation(): void
248  {
249  parent::copyElementOfRelation();
250  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['copiedElementId']);
251  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyElementOfRelation.csv');
252 
253  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
254  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
255  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
256  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
257  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
258  // Referenced elements are not updated at the "parent", which is expected and correct
259  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
260  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
261  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
262  }
263 
267  public function ‪localizeContentOfRelation(): void
268  {
269  parent::localizeContentOfRelation();
270  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
271  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
272 
273  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
274  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
275  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
276  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
277  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
278  }
279 
283  public function ‪localizeElementOfRelation(): void
284  {
285  // Create and publish translated page first
286  $translatedPageResult = $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
287  $this->actionService->publishRecord('pages', $translatedPageResult['pages'][self::VALUE_PageId]);
288  parent::localizeElementOfRelation();
289  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['localizedElementId']);
290  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeElementOfRelation.csv');
291 
292  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
293  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
294  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
295  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
296  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
297  }
298 
303  {
304  parent::moveContentOfRelationToDifferentPage();
305  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
306  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
307 
308  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
309  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
310  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
311  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
312  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
313  }
314 
319  {
320  parent::localizeContentOfRelationWithLocalizeReferencesAtParentLocalization();
321  $this->actionService->publishRecord(self::TABLE_Content, 299);
322  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationWLocalizeReferencesAtParentLocalization.csv');
323  }
324 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:57
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:76
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:147
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:108
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish
Definition: ActionTest.php:18
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:267
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:230
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:302
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:41
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:178
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest
Definition: ActionTest.php:28
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:199
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:283
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:247
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:92
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:214
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: ActionTest.php:318
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:126
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:163