‪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/Publish/DataSet/';
32 
36  protected ‪$assertCleanReferenceIndex = false;
37 
41  public function ‪addElementRelation()
42  {
43  parent::addElementRelation();
44  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
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->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
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->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
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->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
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->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
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->publishRecords([
142  self::TABLE_Content => [$this->recordIds['newContentId']],
143  self::TABLE_Element => [$this->recordIds['newElementId']],
144  ]);
145  $this->‪assertAssertionDataSet('createContentNCreateRelation');
146 
147  $response = $this->executeFrontendRequest(
148  (new InternalRequest())->withPageId(self::VALUE_PageId),
149  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
150  );
151  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
152  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
153  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
154  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
155  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
156  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
157  }
158 
162  public function ‪modifyElementOfRelation()
163  {
164  parent::modifyElementOfRelation();
165  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
166  $this->‪assertAssertionDataSet('modifyElementOfRelation');
167 
168  $response = $this->executeFrontendRequest(
169  (new InternalRequest())->withPageId(self::VALUE_PageId),
170  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
171  );
172  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
173  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
174  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
175  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
176  }
177 
181  public function ‪modifyContentOfRelation()
182  {
183  parent::modifyContentOfRelation();
184  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
185  $this->‪assertAssertionDataSet('modifyContentOfRelation');
186 
187  $response = $this->executeFrontendRequest(
188  (new InternalRequest())->withPageId(self::VALUE_PageId),
189  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
190  );
191  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
192  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
193  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
194  }
195 
199  public function ‪modifyBothSidesOfRelation()
200  {
201  parent::modifyBothSidesOfRelation();
202  $this->actionService->publishRecords([
203  self::TABLE_Content => [self::VALUE_ContentIdFirst],
204  self::TABLE_Element => [self::VALUE_ElementIdFirst],
205  ]);
206  $this->‪assertAssertionDataSet('modifyBothSidesOfRelation');
207 
208  $response = $this->executeFrontendRequest(
209  (new InternalRequest())->withPageId(self::VALUE_PageId),
210  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
211  );
212  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
213  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
214  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
215  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
216  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
217  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
218  }
219 
223  public function ‪deleteContentOfRelation()
224  {
225  parent::deleteContentOfRelation();
226  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
227  $this->‪assertAssertionDataSet('deleteContentOfRelation');
228 
229  $response = $this->executeFrontendRequest(
230  (new InternalRequest())->withPageId(self::VALUE_PageId),
231  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
232  );
233  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
234  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
235  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
236  }
237 
241  public function ‪deleteElementOfRelation()
242  {
243  parent::deleteElementOfRelation();
244  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
245  $this->‪assertAssertionDataSet('deleteElementOfRelation');
246 
247  $response = $this->executeFrontendRequest(
248  (new InternalRequest())->withPageId(self::VALUE_PageId),
249  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
250  );
251  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
252  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
253  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
254  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
255  }
256 
260  public function ‪copyContentOfRelation()
261  {
262  parent::copyContentOfRelation();
263  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
264  $this->‪assertAssertionDataSet('copyContentOfRelation');
265 
266  $response = $this->executeFrontendRequest(
267  (new InternalRequest())->withPageId(self::VALUE_PageId),
268  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
269  );
270  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
271  // Referenced elements are not copied with the "parent", which is expected and correct
272  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
273  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
274  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
275  }
276 
280  public function ‪copyElementOfRelation()
281  {
282  parent::copyElementOfRelation();
283  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['copiedElementId']);
284  $this->‪assertAssertionDataSet('copyElementOfRelation');
285 
286  $response = $this->executeFrontendRequest(
287  (new InternalRequest())->withPageId(self::VALUE_PageId),
288  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
289  );
290  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
291  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
292  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
293  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
294  // Referenced elements are not updated at the "parent", which is expected and correct
295  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
296  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
297  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
298  }
299 
303  public function ‪localizeContentOfRelation()
304  {
305  parent::localizeContentOfRelation();
306  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
307  $this->‪assertAssertionDataSet('localizeContentOfRelation');
308 
309  $response = $this->executeFrontendRequest(
310  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
311  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
312  );
313  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
314  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
315  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
316  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
317  }
318 
322  public function ‪localizeElementOfRelation()
323  {
324  // Create and publish translated page first
325  $translatedPageResult = $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
326  $this->actionService->publishRecord('pages', $translatedPageResult['pages'][self::VALUE_PageId]);
327  parent::localizeElementOfRelation();
328  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['localizedElementId']);
329  $this->‪assertAssertionDataSet('localizeElementOfRelation');
330 
331  $response = $this->executeFrontendRequest(
332  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
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_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
338  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
339  }
340 
345  {
346  parent::moveContentOfRelationToDifferentPage();
347  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
348  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
349 
350  $response = $this->executeFrontendRequest(
351  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
352  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
353  );
354  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
355  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
356  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
357  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
358  }
359 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:136
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:239
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:342
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest
Definition: ActionTest.php:27
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:197
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:221
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:115
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:179
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:34
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:96
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:320
‪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\Publish\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:160
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:80
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:278
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:258
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:58
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish
Definition: ActionTest.php:16
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:301
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Publish\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:39