‪TYPO3CMS  10.4
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
20 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
22 
27 {
31  protected ‪$assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Group/PublishAll/DataSet/';
32 
36  protected ‪$assertCleanReferenceIndex = false;
37 
41  public function ‪addElementRelation()
42  {
43  parent::addElementRelation();
44  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
45  $this->‪assertAssertionDataSet('addElementRelation');
46 
47  $response = $this->executeFrontendRequest(
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()
61  {
62  parent::deleteElementRelation();
63  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
64  $this->‪assertAssertionDataSet('deleteElementRelation');
65 
66  $response = $this->executeFrontendRequest(
67  (new InternalRequest())->withPageId(self::VALUE_PageId),
68  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
69  );
70  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
71  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
72  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
73  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
74  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
75  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
76  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
77  }
78 
82  public function ‪changeElementSorting()
83  {
84  parent::changeElementSorting();
85  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
86  $this->‪assertAssertionDataSet('changeElementSorting');
87 
88  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
89  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
90  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
91  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
92  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
93  }
94 
98  public function ‪changeElementRelationSorting()
99  {
100  parent::changeElementRelationSorting();
101  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
102  $this->‪assertAssertionDataSet('changeElementRelationSorting');
103 
104  $response = $this->executeFrontendRequest(
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 
117  public function ‪createContentAndAddElementRelation()
118  {
119  parent::createContentAndAddElementRelation();
120  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
121  $this->‪assertAssertionDataSet('createContentNAddRelation');
122 
123  $response = $this->executeFrontendRequest(
124  (new InternalRequest())->withPageId(self::VALUE_PageId),
125  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
126  );
127  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
128  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
129  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
130  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
131  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
132  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
133  }
134 
139  {
140  parent::createContentAndCreateElementRelation();
141  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
142  $this->‪assertAssertionDataSet('createContentNCreateRelation');
143 
144  $response = $this->executeFrontendRequest(
145  (new InternalRequest())->withPageId(self::VALUE_PageId),
146  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
147  );
148  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
149  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
150  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
151  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
152  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
153  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
154  }
155 
159  public function ‪modifyElementOfRelation()
160  {
161  parent::modifyElementOfRelation();
162  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
163  $this->‪assertAssertionDataSet('modifyElementOfRelation');
164 
165  $response = $this->executeFrontendRequest(
166  (new InternalRequest())->withPageId(self::VALUE_PageId),
167  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
168  );
169  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
170  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
171  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
172  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
173  }
174 
178  public function ‪modifyContentOfRelation()
179  {
180  parent::modifyContentOfRelation();
181  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
182  $this->‪assertAssertionDataSet('modifyContentOfRelation');
183 
184  $response = $this->executeFrontendRequest(
185  (new InternalRequest())->withPageId(self::VALUE_PageId),
186  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
187  );
188  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
189  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
190  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
191  }
192 
196  public function ‪modifyBothSidesOfRelation()
197  {
198  parent::modifyBothSidesOfRelation();
199  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
200  $this->‪assertAssertionDataSet('modifyBothSidesOfRelation');
201 
202  $response = $this->executeFrontendRequest(
203  (new InternalRequest())->withPageId(self::VALUE_PageId),
204  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
205  );
206  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
207  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
208  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
209  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
210  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
211  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
212  }
213 
217  public function ‪deleteContentOfRelation()
218  {
219  parent::deleteContentOfRelation();
220  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
221  $this->‪assertAssertionDataSet('deleteContentOfRelation');
222 
223  $response = $this->executeFrontendRequest(
224  (new InternalRequest())->withPageId(self::VALUE_PageId),
225  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
226  );
227  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
228  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
229  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
230  }
231 
235  public function ‪deleteElementOfRelation()
236  {
237  parent::deleteElementOfRelation();
238  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
239  $this->‪assertAssertionDataSet('deleteElementOfRelation');
240 
241  $response = $this->executeFrontendRequest(
242  (new InternalRequest())->withPageId(self::VALUE_PageId),
243  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
244  );
245  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
246  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
247  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
248  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
249  }
250 
254  public function ‪copyContentOfRelation()
255  {
256  parent::copyContentOfRelation();
257  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
258  $this->‪assertAssertionDataSet('copyContentOfRelation');
259 
260  $response = $this->executeFrontendRequest(
261  (new InternalRequest())->withPageId(self::VALUE_PageId),
262  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
263  );
264  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
265  // Referenced elements are not copied with the "parent", which is expected and correct
266  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
267  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
268  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
269  }
270 
274  public function ‪copyElementOfRelation()
275  {
276  parent::copyElementOfRelation();
277  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
278  $this->‪assertAssertionDataSet('copyElementOfRelation');
279 
280  $response = $this->executeFrontendRequest(
281  (new InternalRequest())->withPageId(self::VALUE_PageId),
282  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
283  );
284  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
285  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
286  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
287  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
288  // Referenced elements are not updated at the "parent", which is expected and correct
289  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
290  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
291  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
292  }
293 
297  public function ‪localizeContentOfRelation()
298  {
299  parent::localizeContentOfRelation();
300  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
301  $this->‪assertAssertionDataSet('localizeContentOfRelation');
302 
303  $response = $this->executeFrontendRequest(
304  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
305  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
306  );
307  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
308  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
309  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
310  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
311  }
312 
316  public function ‪localizeElementOfRelation()
317  {
318  // Create translated page first
319  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
320  parent::localizeElementOfRelation();
321  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
322  $this->‪assertAssertionDataSet('localizeElementOfRelation');
323 
324  $response = $this->executeFrontendRequest(
325  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
326  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
327  );
328  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
329  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
330  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
331  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
332  }
333 
338  {
339  parent::moveContentOfRelationToDifferentPage();
340  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
341  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
342 
343  $response = $this->executeFrontendRequest(
344  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
345  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
346  );
347  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
348  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
349  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
350  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
351  }
352 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll
Definition: ActionTest.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:215
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:295
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:194
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:136
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:157
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:252
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:314
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:176
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest
Definition: ActionTest.php:27
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:115
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\assertAssertionDataSet
‪assertAssertionDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:208
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:297
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:58
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:96
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:335
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:233
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:80
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:34
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\PublishAll\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:272