‪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/ManyToMany/PublishAll/DataSet/';
31 
35  protected ‪$assertCleanReferenceIndex = false;
36 
40  public function ‪addCategoryRelation()
41  {
42  parent::addCategoryRelation();
43  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
44  $this->‪assertAssertionDataSet('addCategoryRelation');
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('categories')
50  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B', 'Category A.A'));
51  }
52 
56  public function ‪deleteCategoryRelation()
57  {
58  parent::deleteCategoryRelation();
59  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
60  $this->‪assertAssertionDataSet('deleteCategoryRelation');
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('categories')
66  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
67  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
68  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
69  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
70  }
71 
75  public function ‪changeCategoryRelationSorting()
76  {
77  parent::changeCategoryRelationSorting();
78  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
79  $this->‪assertAssertionDataSet('changeCategoryRelationSorting');
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('categories')
85  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
86  }
87 
91  public function ‪createContentAndAddRelation()
92  {
93  parent::createContentAndAddRelation();
94  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
95  $this->‪assertAssertionDataSet('createContentNAddRelation');
96 
97  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
98  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
99  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
100  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
101  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
102  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
103  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B'));
104  }
105 
109  public function ‪createCategoryAndAddRelation()
110  {
111  parent::createCategoryAndAddRelation();
112  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
113  $this->‪assertAssertionDataSet('createCategoryNAddRelation');
114 
115  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
116  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
117  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
118  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
119  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
120  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
121  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
122  }
123 
127  public function ‪createContentAndCreateRelation()
128  {
129  parent::createContentAndCreateRelation();
130  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
131  $this->‪assertAssertionDataSet('createContentNCreateRelation');
132 
133  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
134  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
135  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
136  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
137  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
138  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
139  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
140  }
141 
145  public function ‪createCategoryAndCreateRelation()
146  {
147  parent::createCategoryAndCreateRelation();
148  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
149  $this->‪assertAssertionDataSet('createCategoryNCreateRelation');
150  }
151 
156  {
157  parent::createContentWithCategoryAndAddRelation();
158  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
159  $this->‪assertAssertionDataSet('createContentWCategoryNAddRelation');
160  }
161 
166  {
167  parent::createCategoryWithContentAndAddRelation();
168  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
169  $this->‪assertAssertionDataSet('createCategoryWContentNAddRelation');
170  }
171 
175  public function ‪modifyCategoryOfRelation()
176  {
177  parent::modifyCategoryOfRelation();
178  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
179  $this->‪assertAssertionDataSet('modifyCategoryOfRelation');
180 
181  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
182  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
183  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
184  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
185  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
186  }
187 
191  public function ‪modifyContentOfRelation()
192  {
193  parent::modifyContentOfRelation();
194  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
195  $this->‪assertAssertionDataSet('modifyContentOfRelation');
196 
197  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
198  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
199  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
200  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
201  }
202 
206  public function ‪modifyBothsOfRelation()
207  {
208  parent::modifyBothsOfRelation();
209  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
210  $this->‪assertAssertionDataSet('modifyBothsOfRelation');
211 
212  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
213  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
214  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
215  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
216  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
217  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
218  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
219  }
220 
224  public function ‪deleteContentOfRelation()
225  {
226  parent::deleteContentOfRelation();
227  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
228  $this->‪assertAssertionDataSet('deleteContentOfRelation');
229 
230  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
231  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
232  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
233  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
234  }
235 
239  public function ‪deleteCategoryOfRelation()
240  {
241  parent::deleteCategoryOfRelation();
242  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
243  $this->‪assertAssertionDataSet('deleteCategoryOfRelation');
244 
245  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
246  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
247  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
248  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
249  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
250  }
251 
255  public function ‪copyContentOfRelation()
256  {
257  parent::copyContentOfRelation();
258  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
259  $this->‪assertAssertionDataSet('copyContentOfRelation');
260 
261  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
262  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
263  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
264  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
265  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
266  }
267 
271  public function ‪copyCategoryOfRelation()
272  {
273  parent::copyCategoryOfRelation();
274  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
275  $this->‪assertAssertionDataSet('copyCategoryOfRelation');
276 
277  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
278  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
279  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
280  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
281  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category A (copy 1)'));
282  }
283 
287  public function ‪localizeContentOfRelation()
288  {
289  parent::localizeContentOfRelation();
290  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
291  $this->‪assertAssertionDataSet('localizeContentOfRelation');
292 
293  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
294  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
295  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
296  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
297  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
298  }
299 
303  public function ‪localizeCategoryOfRelation()
304  {
305  // Create translated page first
306  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
307  parent::localizeCategoryOfRelation();
308  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
309  $this->‪assertAssertionDataSet('localizeCategoryOfRelation');
310 
311  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
312  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
313  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
314  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
315  ->setTable(self::TABLE_Category)->setField('title')->setValues('[Translate to Dansk:] Category A', 'Category B'));
316  }
317 
322  {
323  parent::moveContentOfRelationToDifferentPage();
324  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
325  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
326 
327  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
328  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
329  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
330  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
331  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
332  }
333 
337  public function ‪copyPage()
338  {
339  parent::copyPage();
340  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
341  $this->‪assertAssertionDataSet('copyPage');
342 
343  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId($this->recordIds['newPageId']));
344  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
345  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
346  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
347  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
348  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
349  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
350  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'])->setRecordField('categories')
351  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
352  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
353  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'])->setRecordField('categories')
354  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
355  }
356 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\deleteCategoryRelation
‪deleteCategoryRelation()
Definition: ActionTest.php:54
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:319
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\modifyBothsOfRelation
‪modifyBothsOfRelation()
Definition: ActionTest.php:204
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createCategoryWithContentAndAddRelation
‪createCategoryWithContentAndAddRelation()
Definition: ActionTest.php:163
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll
Definition: ActionTest.php:16
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\modifyCategoryOfRelation
‪modifyCategoryOfRelation()
Definition: ActionTest.php:173
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createCategoryAndAddRelation
‪createCategoryAndAddRelation()
Definition: ActionTest.php:107
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:222
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:285
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\addCategoryRelation
‪addCategoryRelation()
Definition: ActionTest.php:38
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:189
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createCategoryAndCreateRelation
‪createCategoryAndCreateRelation()
Definition: ActionTest.php:143
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\copyCategoryOfRelation
‪copyCategoryOfRelation()
Definition: ActionTest.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createContentWithCategoryAndAddRelation
‪createContentWithCategoryAndAddRelation()
Definition: ActionTest.php:153
‪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\ManyToMany\PublishAll\ActionTest\copyPage
‪copyPage()
Definition: ActionTest.php:335
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\localizeCategoryOfRelation
‪localizeCategoryOfRelation()
Definition: ActionTest.php:301
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\deleteCategoryOfRelation
‪deleteCategoryOfRelation()
Definition: ActionTest.php:237
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createContentAndCreateRelation
‪createContentAndCreateRelation()
Definition: ActionTest.php:125
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createContentAndAddRelation
‪createContentAndAddRelation()
Definition: ActionTest.php:89
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\changeCategoryRelationSorting
‪changeCategoryRelationSorting()
Definition: ActionTest.php:73