‪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->actionService->publishWorkspace(self::VALUE_WorkspaceId);
46  $this->assertCSVDataSet(__DIR__ . '/DataSet/addElementRelation.csv');
47 
48  $response = $this->executeFrontendSubRequest(
49  (new InternalRequest())->withPageId(self::VALUE_PageId),
50  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
51  );
52  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
53  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
54  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
55  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
56  }
57 
61  public function ‪deleteElementRelation(): void
62  {
63  parent::deleteElementRelation();
64  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
65  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementRelation.csv');
66 
67  $response = $this->executeFrontendSubRequest(
68  (new InternalRequest())->withPageId(self::VALUE_PageId),
69  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
70  );
71  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
72  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
73  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
74  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
75  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
76  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
77  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
78  }
79 
83  public function ‪changeElementSorting(): void
84  {
85  parent::changeElementSorting();
86  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
87  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeElementSorting.csv');
88 
89  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
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->actionService->publishWorkspace(self::VALUE_WorkspaceId);
103  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeElementRelationSorting.csv');
104 
105  $response = $this->executeFrontendSubRequest(
106  (new InternalRequest())->withPageId(self::VALUE_PageId),
107  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
108  );
109  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
110  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
111  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
112  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
113  }
114 
119  {
120  parent::createContentAndAddElementRelation();
121  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
122  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNAddRelation.csv');
123 
124  $response = $this->executeFrontendSubRequest(
125  (new InternalRequest())->withPageId(self::VALUE_PageId),
126  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
127  );
128  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
129  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
130  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
131  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
132  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
133  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
134  }
135 
140  {
141  parent::createContentAndCreateElementRelation();
142  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
143  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNCreateRelation.csv');
144 
145  $response = $this->executeFrontendSubRequest(
146  (new InternalRequest())->withPageId(self::VALUE_PageId),
147  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
148  );
149  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
150  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
151  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
152  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
153  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
154  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
155  }
156 
160  public function ‪modifyElementOfRelation(): void
161  {
162  parent::modifyElementOfRelation();
163  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
164  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyElementOfRelation.csv');
165 
166  $response = $this->executeFrontendSubRequest(
167  (new InternalRequest())->withPageId(self::VALUE_PageId),
168  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
169  );
170  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
171  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
172  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
173  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
174  }
175 
179  public function ‪modifyContentOfRelation(): void
180  {
181  parent::modifyContentOfRelation();
182  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
183  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentOfRelation.csv');
184 
185  $response = $this->executeFrontendSubRequest(
186  (new InternalRequest())->withPageId(self::VALUE_PageId),
187  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
188  );
189  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
190  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
191  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
192  }
193 
197  public function ‪modifyBothSidesOfRelation(): void
198  {
199  parent::modifyBothSidesOfRelation();
200  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
201  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyBothSidesOfRelation.csv');
202 
203  $response = $this->executeFrontendSubRequest(
204  (new InternalRequest())->withPageId(self::VALUE_PageId),
205  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
206  );
207  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
208  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
209  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
210  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
211  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
212  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
213  }
214 
218  public function ‪deleteContentOfRelation(): void
219  {
220  parent::deleteContentOfRelation();
221  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
222  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContentOfRelation.csv');
223 
224  $response = $this->executeFrontendSubRequest(
225  (new InternalRequest())->withPageId(self::VALUE_PageId),
226  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
227  );
228  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
229  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
230  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
231  }
232 
236  public function ‪deleteElementOfRelation(): void
237  {
238  parent::deleteElementOfRelation();
239  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
240  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteElementOfRelation.csv');
241 
242  $response = $this->executeFrontendSubRequest(
243  (new InternalRequest())->withPageId(self::VALUE_PageId),
244  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
245  );
246  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
247  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
248  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
249  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
250  }
251 
255  public function ‪copyContentOfRelation(): void
256  {
257  parent::copyContentOfRelation();
258  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
259  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentOfRelation.csv');
260 
261  $response = $this->executeFrontendSubRequest(
262  (new InternalRequest())->withPageId(self::VALUE_PageId),
263  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
264  );
265  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
266  // Referenced elements are not copied with the "parent", which is expected and correct
267  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
268  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
269  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
270  }
271 
275  public function ‪copyElementOfRelation(): void
276  {
277  parent::copyElementOfRelation();
278  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
279  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyElementOfRelation.csv');
280 
281  $response = $this->executeFrontendSubRequest(
282  (new InternalRequest())->withPageId(self::VALUE_PageId),
283  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
284  );
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'));
289  // Referenced elements are not updated at the "parent", which is expected and correct
290  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
291  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
292  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
293  }
294 
298  public function ‪localizeContentOfRelation(): void
299  {
300  parent::localizeContentOfRelation();
301  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
302  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
303 
304  $response = $this->executeFrontendSubRequest(
305  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
306  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
307  );
308  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
309  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
310  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
311  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
312  }
313 
317  public function ‪localizeElementOfRelation(): void
318  {
319  // Create translated page first
320  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
321  parent::localizeElementOfRelation();
322  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
323  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeElementOfRelation.csv');
324 
325  $response = $this->executeFrontendSubRequest(
326  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
327  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
328  );
329  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
330  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
331  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
332  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
333  }
334 
339  {
340  parent::moveContentOfRelationToDifferentPage();
341  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
342  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
343 
344  $response = $this->executeFrontendSubRequest(
345  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
346  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
347  );
348  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
349  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
350  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
351  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
352  }
353 
358  {
359  parent::localizeContentOfRelationWithLocalizeReferencesAtParentLocalization();
360  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
361  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationWLocalizeReferencesAtParentLocalization.csv');
362  }
363 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll
Definition: ActionTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:218
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:298
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:197
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:139
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: ActionTest.php:357
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:160
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:255
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:317
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:179
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest
Definition: ActionTest.php:29
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:118
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:61
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:99
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:338
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:236
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:83
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:275