‪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\ResponseContent;
21 
26 {
30  protected ‪$assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Select/PublishAll/DataSet/';
31 
35  protected ‪$assertCleanReferenceIndex = false;
36 
40  public function ‪addElementRelation()
41  {
42  parent::addElementRelation();
43  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
44  $this->‪assertAssertionDataSet('addElementRelation');
45 
46  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
47  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
48  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
49  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
50  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
51  }
52 
56  public function ‪deleteElementRelation()
57  {
58  parent::deleteElementRelation();
59  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
60  $this->‪assertAssertionDataSet('deleteElementRelation');
61 
62  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
63  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
64  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
65  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
66  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
67  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
68  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
69  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
70  }
71 
75  public function ‪changeElementSorting()
76  {
77  parent::changeElementSorting();
78  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
79  $this->‪assertAssertionDataSet('changeElementSorting');
80 
81  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
82  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
83  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
84  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
85  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
86  }
87 
91  public function ‪changeElementRelationSorting()
92  {
93  parent::changeElementRelationSorting();
94  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
95  $this->‪assertAssertionDataSet('changeElementRelationSorting');
96 
97  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
98  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
99  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
100  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
101  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
102  }
103 
107  public function ‪createContentAndAddElementRelation()
108  {
109  parent::createContentAndAddElementRelation();
110  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
111  $this->‪assertAssertionDataSet('createContentNAddRelation');
112 
113  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
114  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
115  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
116  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
117  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
118  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
119  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
120  }
121 
126  {
127  parent::createContentAndCreateElementRelation();
128  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
129  $this->‪assertAssertionDataSet('createContentNCreateRelation');
130 
131  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
132  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
133  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
134  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
135  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
136  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
137  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
138  }
139 
143  public function ‪modifyElementOfRelation()
144  {
145  parent::modifyElementOfRelation();
146  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
147  $this->‪assertAssertionDataSet('modifyElementOfRelation');
148 
149  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
150  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
151  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
152  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
153  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
154  }
155 
159  public function ‪modifyContentOfRelation()
160  {
161  parent::modifyContentOfRelation();
162  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
163  $this->‪assertAssertionDataSet('modifyContentOfRelation');
164 
165  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
166  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
167  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
168  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
169  }
170 
174  public function ‪modifyBothSidesOfRelation()
175  {
176  parent::modifyBothSidesOfRelation();
177  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
178  $this->‪assertAssertionDataSet('modifyBothSidesOfRelation');
179 
180  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
181  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
182  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
183  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
184  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
185  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
186  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
187  }
188 
192  public function ‪deleteContentOfRelation()
193  {
194  parent::deleteContentOfRelation();
195  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
196  $this->‪assertAssertionDataSet('deleteContentOfRelation');
197 
198  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
199  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
200  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
201  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
202  }
203 
207  public function ‪deleteElementOfRelation()
208  {
209  parent::deleteElementOfRelation();
210  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
211  $this->‪assertAssertionDataSet('deleteElementOfRelation');
212 
213  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
214  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
215  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
216  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
217  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
218  }
219 
223  public function ‪copyContentOfRelation()
224  {
225  parent::copyContentOfRelation();
226  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
227  $this->‪assertAssertionDataSet('copyContentOfRelation');
228 
229  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
230  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
231  // Referenced elements are not copied with the "parent", which is expected and correct
232  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
233  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
234  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
235  }
236 
240  public function ‪copyElementOfRelation()
241  {
242  parent::copyElementOfRelation();
243  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
244  $this->‪assertAssertionDataSet('copyElementOfRelation');
245 
246  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
247  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
248  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
249  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
250  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
251  // Referenced elements are not updated at the "parent", which is expected and correct
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 (copy 1)'));
255  }
256 
260  public function ‪localizeContentOfRelation()
261  {
262  parent::localizeContentOfRelation();
263  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
264  $this->‪assertAssertionDataSet('localizeContentOfRelation');
265 
266  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
267  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
268  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
269  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
270  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
271  }
272 
276  public function ‪localizeElementOfRelation()
277  {
278  // Create translated page first
279  $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
280  parent::localizeElementOfRelation();
281  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
282  $this->‪assertAssertionDataSet('localizeElementOfRelation');
283 
284  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
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('[Translate to Dansk:] Element #1', 'Element #2'));
289  }
290 
295  {
296  parent::moveContentOfRelationToDifferentPage();
297  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
298  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
299 
300  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
301  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
302  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
303  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
304  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
305  }
306 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:205
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:89
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:123
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:238
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:274
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll
Definition: ActionTest.php:16
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:258
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:73
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:54
‪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\Select\PublishAll\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:141
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:38
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:292
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:190
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:172
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:157
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:221
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\PublishAll\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:105
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22