‪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\InternalRequestContext;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
24 
29 {
33  public function ‪verifyCleanReferenceIndex(): void
34  {
35  // The test verifies the imported data set has a clean reference index by the check in tearDown()
36  self::assertTrue(true);
37  }
38 
42  public function ‪addElementRelation(): void
43  {
44  parent::addElementRelation();
45  $this->assertCSVDataSet(__DIR__ . '/DataSet/addElementRelation.csv');
46 
47  $response = $this->executeFrontendSubRequest(
48  (new InternalRequest())->withPageId(self::VALUE_PageId),
49  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
50  );
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 
60  public function ‪deleteElementRelation(): void
61  {
62  parent::deleteElementRelation();
63  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementRelation.csv');
64 
65  $response = $this->executeFrontendSubRequest(
66  (new InternalRequest())->withPageId(self::VALUE_PageId),
67  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
68  );
69  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
70  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
71  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
72  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
73  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
74  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
75  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
76  }
77 
81  public function ‪changeElementSorting(): void
82  {
83  parent::changeElementSorting();
84  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeElementSorting.csv');
85 
86  $response = $this->executeFrontendSubRequest(
87  (new InternalRequest())->withPageId(self::VALUE_PageId),
88  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
89  );
90  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
91  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
92  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
93  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
94  }
95 
99  public function ‪changeElementRelationSorting(): void
100  {
101  parent::changeElementRelationSorting();
102  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeElementRelationSorting.csv');
103 
104  $response = $this->executeFrontendSubRequest(
105  (new InternalRequest())->withPageId(self::VALUE_PageId),
106  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
107  );
108  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
109  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
110  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
111  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
112  }
113 
118  {
119  parent::createContentAndAddElementRelation();
120  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNAddRelation.csv');
121 
122  $response = $this->executeFrontendSubRequest(
123  (new InternalRequest())->withPageId(self::VALUE_PageId),
124  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
125  );
126  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
127  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
128  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
129  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
130  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
131  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
132  }
133 
138  {
139  parent::createContentAndCreateElementRelation();
140  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNCreateRelation.csv');
141 
142  $response = $this->executeFrontendSubRequest(
143  (new InternalRequest())->withPageId(self::VALUE_PageId),
144  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
145  );
146  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
147  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
148  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
149  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
150  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
151  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
152  }
153 
157  public function ‪modifyElementOfRelation(): void
158  {
159  parent::modifyElementOfRelation();
160  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyElementOfRelation.csv');
161 
162  $response = $this->executeFrontendSubRequest(
163  (new InternalRequest())->withPageId(self::VALUE_PageId),
164  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
165  );
166  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
167  self::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  }
171 
175  public function ‪modifyContentOfRelation(): void
176  {
177  parent::modifyContentOfRelation();
178  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentOfRelation.csv');
179 
180  $response = $this->executeFrontendSubRequest(
181  (new InternalRequest())->withPageId(self::VALUE_PageId),
182  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
183  );
184  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
185  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
186  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
187  }
188 
192  public function ‪modifyBothSidesOfRelation(): void
193  {
194  parent::modifyBothSidesOfRelation();
195  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyBothSidesOfRelation.csv');
196 
197  $response = $this->executeFrontendSubRequest(
198  (new InternalRequest())->withPageId(self::VALUE_PageId),
199  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
200  );
201  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
202  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
203  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
204  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
205  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
206  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
207  }
208 
212  public function ‪deleteContentOfRelation(): void
213  {
214  parent::deleteContentOfRelation();
215  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContentOfRelation.csv');
216 
217  $response = $this->executeFrontendSubRequest(
218  (new InternalRequest())->withPageId(self::VALUE_PageId),
219  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
220  );
221  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
222  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
223  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
224  }
225 
229  public function ‪deleteElementOfRelation(): void
230  {
231  parent::deleteElementOfRelation();
232  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementOfRelation.csv');
233 
234  $response = $this->executeFrontendSubRequest(
235  (new InternalRequest())->withPageId(self::VALUE_PageId),
236  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
237  );
238  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
239  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
240  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
241  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
242  }
243 
247  public function ‪copyContentOfRelation(): void
248  {
249  parent::copyContentOfRelation();
250  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentOfRelation.csv');
251 
252  $response = $this->executeFrontendSubRequest(
253  (new InternalRequest())->withPageId(self::VALUE_PageId),
254  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
255  );
256  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
257  // Referenced elements are not copied with the "parent", which is expected and correct
258  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
259  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
260  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
261  }
262 
266  public function ‪copyElementOfRelation(): void
267  {
268  parent::copyElementOfRelation();
269  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyElementOfRelation.csv');
270 
271  $response = $this->executeFrontendSubRequest(
272  (new InternalRequest())->withPageId(self::VALUE_PageId),
273  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
274  );
275  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
276  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
277  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
278  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
279  // Referenced elements are not updated at the "parent", which is expected and correct
280  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
281  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
282  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
283  }
284 
288  public function ‪localizeContentOfRelation(): void
289  {
290  parent::localizeContentOfRelation();
291  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
292 
293  $response = $this->executeFrontendSubRequest(
294  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
295  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
296  );
297  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
298  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
299  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
300  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
301  }
302 
306  public function ‪localizeElementOfRelation(): void
307  {
308  // Create translated page first
309  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
310  parent::localizeElementOfRelation();
311  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeElementOfRelation.csv');
312 
313  $response = $this->executeFrontendSubRequest(
314  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
315  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
316  );
317  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
318  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
319  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
320  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
321  }
322 
327  {
328  parent::moveContentOfRelationToDifferentPage();
329  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
330 
331  $response = $this->executeFrontendSubRequest(
332  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
333  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
334  );
335  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
336  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
337  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
338  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
339  }
340 
345  {
346  parent::localizeContentOfRelationWithLocalizeReferencesAtParentLocalization();
347  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationWLocalizeReferencesAtParentLocalization.csv');
348  }
349 }
‪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\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:137
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:99
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:192
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:266
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:175
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:117
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:326
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:306
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:212
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:288
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:42
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:247
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:60
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:81
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:229
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest
Definition: ActionTest.php:29
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: ActionTest.php:344
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify
Definition: ActionTest.php:18
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:157