‪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/Modify/DataSet/';
32 
36  protected ‪$assertCleanReferenceIndex = false;
37 
41  public function ‪addElementRelation()
42  {
43  parent::addElementRelation();
44  $this->‪assertAssertionDataSet('addElementRelation');
45 
46  $response = $this->executeFrontendRequest(
47  (new InternalRequest())->withPageId(self::VALUE_PageId),
48  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
49  );
50  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
51  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
52  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
53  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
54  }
55 
59  public function ‪deleteElementRelation()
60  {
61  parent::deleteElementRelation();
62  $this->‪assertAssertionDataSet('deleteElementRelation');
63 
64  $response = $this->executeFrontendRequest(
65  (new InternalRequest())->withPageId(self::VALUE_PageId),
66  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
67  );
68  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
69  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
70  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
71  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
72  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
73  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
74  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
75  }
76 
80  public function ‪changeElementSorting()
81  {
82  parent::changeElementSorting();
83  $this->‪assertAssertionDataSet('changeElementSorting');
84 
85  $response = $this->executeFrontendRequest(
86  (new InternalRequest())->withPageId(self::VALUE_PageId),
87  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
88  );
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->‪assertAssertionDataSet('changeElementRelationSorting');
102 
103  $response = $this->executeFrontendRequest(
104  (new InternalRequest())->withPageId(self::VALUE_PageId),
105  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
106  );
107  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
108  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
109  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
110  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
111  }
112 
116  public function ‪createContentAndAddElementRelation()
117  {
118  parent::createContentAndAddElementRelation();
119  $this->‪assertAssertionDataSet('createContentNAddRelation');
120 
121  $response = $this->executeFrontendRequest(
122  (new InternalRequest())->withPageId(self::VALUE_PageId),
123  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
124  );
125  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
126  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
127  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
128  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
129  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
130  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
131  }
132 
137  {
138  parent::createContentAndCreateElementRelation();
139  $this->‪assertAssertionDataSet('createContentNCreateRelation');
140 
141  $response = $this->executeFrontendRequest(
142  (new InternalRequest())->withPageId(self::VALUE_PageId),
143  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
144  );
145  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
146  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
147  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
148  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
149  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
150  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
151  }
152 
156  public function ‪modifyElementOfRelation()
157  {
158  parent::modifyElementOfRelation();
159  $this->‪assertAssertionDataSet('modifyElementOfRelation');
160 
161  $response = $this->executeFrontendRequest(
162  (new InternalRequest())->withPageId(self::VALUE_PageId),
163  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
164  );
165  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
166  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
167  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
168  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
169  }
170 
174  public function ‪modifyContentOfRelation()
175  {
176  parent::modifyContentOfRelation();
177  $this->‪assertAssertionDataSet('modifyContentOfRelation');
178 
179  $response = $this->executeFrontendRequest(
180  (new InternalRequest())->withPageId(self::VALUE_PageId),
181  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
182  );
183  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
184  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
185  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
186  }
187 
191  public function ‪modifyBothSidesOfRelation()
192  {
193  parent::modifyBothSidesOfRelation();
194  $this->‪assertAssertionDataSet('modifyBothSidesOfRelation');
195 
196  $response = $this->executeFrontendRequest(
197  (new InternalRequest())->withPageId(self::VALUE_PageId),
198  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
199  );
200  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
201  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
202  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
203  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
204  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
205  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
206  }
207 
211  public function ‪deleteContentOfRelation()
212  {
213  parent::deleteContentOfRelation();
214  $this->‪assertAssertionDataSet('deleteContentOfRelation');
215 
216  $response = $this->executeFrontendRequest(
217  (new InternalRequest())->withPageId(self::VALUE_PageId),
218  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
219  );
220  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
221  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
222  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
223  }
224 
228  public function ‪deleteElementOfRelation()
229  {
230  parent::deleteElementOfRelation();
231  $this->‪assertAssertionDataSet('deleteElementOfRelation');
232 
233  $response = $this->executeFrontendRequest(
234  (new InternalRequest())->withPageId(self::VALUE_PageId),
235  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
236  );
237  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
238  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
239  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
240  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
241  }
242 
246  public function ‪copyContentOfRelation()
247  {
248  parent::copyContentOfRelation();
249  $this->‪assertAssertionDataSet('copyContentOfRelation');
250 
251  $response = $this->executeFrontendRequest(
252  (new InternalRequest())->withPageId(self::VALUE_PageId),
253  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
254  );
255  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
256  // Referenced elements are not copied with the "parent", which is expected and correct
257  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
258  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
259  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
260  }
261 
265  public function ‪copyElementOfRelation()
266  {
267  parent::copyElementOfRelation();
268  $this->‪assertAssertionDataSet('copyElementOfRelation');
269 
270  $response = $this->executeFrontendRequest(
271  (new InternalRequest())->withPageId(self::VALUE_PageId),
272  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
273  );
274  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
275  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
276  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
277  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
278  // Referenced elements are not updated at the "parent", which is expected and correct
279  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
280  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
281  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
282  }
283 
287  public function ‪localizeContentOfRelation()
288  {
289  parent::localizeContentOfRelation();
290  $this->‪assertAssertionDataSet('localizeContentOfRelation');
291 
292  $response = $this->executeFrontendRequest(
293  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
294  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
295  );
296  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
297  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
298  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
299  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
300  }
301 
305  public function ‪localizeElementOfRelation()
306  {
307  // Create translated page first
308  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
309  parent::localizeElementOfRelation();
310  $this->‪assertAssertionDataSet('localizeElementOfRelation');
311 
312  $response = $this->executeFrontendRequest(
313  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
314  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
315  );
316  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
317  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
318  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
319  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
320  }
321 
326  {
327  parent::moveContentOfRelationToDifferentPage();
328  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
329 
330  $response = $this->executeFrontendRequest(
331  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
332  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
333  );
334  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
335  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
336  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
337  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
338  }
339 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:134
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:96
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:189
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:30
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:263
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:172
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:114
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:323
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:303
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:209
‪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\Modify\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:285
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:39
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:244
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:57
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:78
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:226
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest
Definition: ActionTest.php:27
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:34
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify
Definition: ActionTest.php:16
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Group\Modify\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:154