‪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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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 
144  public function ‪modifyElementOfRelation(): void
145  {
146  parent::modifyElementOfRelation();
147  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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 
160  public function ‪modifyContentOfRelation(): void
161  {
162  parent::modifyContentOfRelation();
163  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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 
175  public function ‪modifyBothSidesOfRelation(): void
176  {
177  parent::modifyBothSidesOfRelation();
178  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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 
193  public function ‪deleteContentOfRelation(): void
194  {
195  parent::deleteContentOfRelation();
196  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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 
208  public function ‪deleteElementOfRelation(): void
209  {
210  parent::deleteElementOfRelation();
211  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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 
224  public function ‪copyContentOfRelation(): void
225  {
226  parent::copyContentOfRelation();
227  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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  // Referenced elements are not copied with the "parent", which is expected and correct
233  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
234  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
235  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
236  }
237 
241  public function ‪copyElementOfRelation(): void
242  {
243  parent::copyElementOfRelation();
244  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
245  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyElementOfRelation.csv');
246 
247  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
248  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
249  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
250  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
251  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
252  // Referenced elements are not updated at the "parent", which is expected and correct
253  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
254  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
255  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
256  }
257 
261  public function ‪localizeContentOfRelation(): void
262  {
263  parent::localizeContentOfRelation();
264  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
265  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
266 
267  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
268  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
269  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
270  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
271  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
272  }
273 
277  public function ‪localizeElementOfRelation(): void
278  {
279  // Create translated page first
280  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
281  parent::localizeElementOfRelation();
282  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
283  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeElementOfRelation.csv');
284 
285  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
286  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
287  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
288  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
289  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
290  }
291 
296  {
297  parent::moveContentOfRelationToDifferentPage();
298  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
299  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
300 
301  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
302  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
303  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
304  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
305  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
306  }
307 
312  {
313  parent::localizeContentOfRelationWithLocalizeReferencesAtParentLocalization();
314  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
315  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationWLocalizeReferencesAtParentLocalization.csv');
316  }
317 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:208
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: ActionTest.php:311
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:92
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:126
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:241
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:277
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll
Definition: ActionTest.php:18
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest
Definition: ActionTest.php:28
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:76
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:57
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:144
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:41
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:295
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:193
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:175
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:160
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:224
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:108
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24