‪TYPO3CMS  11.5
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
23 
28 {
32  public function ‪verifyCleanReferenceIndex(): void
33  {
34  // The test verifies the imported data set has a clean reference index by the check in tearDown()
35  self::assertTrue(true);
36  }
37 
41  public function ‪addCategoryRelation(): void
42  {
43  parent::addCategoryRelation();
44  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
45  $this->assertCSVDataSet(__DIR__ . '/DataSet/addCategoryRelation.csv');
46 
47  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
48  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
49  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
50  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
51  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B', 'Category A.A'));
52  }
53 
57  public function ‪deleteCategoryRelation(): void
58  {
59  parent::deleteCategoryRelation();
60  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
61  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteCategoryRelation.csv');
62 
63  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
64  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
65  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
66  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
67  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
68  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
69  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
70  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
71  }
72 
76  public function ‪changeCategoryRelationSorting(): void
77  {
78  parent::changeCategoryRelationSorting();
79  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
80  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeCategoryRelationSorting.csv');
81 
82  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
83  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
84  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
85  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
86  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
87  }
88 
92  public function ‪createContentAndAddRelation(): void
93  {
94  parent::createContentAndAddRelation();
95  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
96  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNAddRelation.csv');
97 
98  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
99  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
100  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
101  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
102  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
103  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
104  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B'));
105  }
106 
110  public function ‪createCategoryAndAddRelation(): void
111  {
112  parent::createCategoryAndAddRelation();
113  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
114  $this->assertCSVDataSet(__DIR__ . '/DataSet/createCategoryNAddRelation.csv');
115 
116  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
117  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
118  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
119  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
120  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
121  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
122  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
123  }
124 
128  public function ‪createContentAndCreateRelation(): void
129  {
130  parent::createContentAndCreateRelation();
131  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
132  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentNCreateRelation.csv');
133 
134  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
135  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
136  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
137  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
138  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
139  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
140  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
141  }
142 
146  public function ‪createCategoryAndCreateRelation(): void
147  {
148  parent::createCategoryAndCreateRelation();
149  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
150  $this->assertCSVDataSet(__DIR__ . '/DataSet/createCategoryNCreateRelation.csv');
151  }
152 
157  {
158  parent::createContentWithCategoryAndAddRelation();
159  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
160  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentWCategoryNAddRelation.csv');
161  }
162 
167  {
168  parent::createCategoryWithContentAndAddRelation();
169  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
170  $this->assertCSVDataSet(__DIR__ . '/DataSet/createCategoryWContentNAddRelation.csv');
171  }
172 
176  public function ‪modifyCategoryOfRelation(): void
177  {
178  parent::modifyCategoryOfRelation();
179  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
180  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyCategoryOfRelation.csv');
181 
182  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
183  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
184  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
185  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
186  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
187  }
188 
192  public function ‪modifyContentOfRelation(): void
193  {
194  parent::modifyContentOfRelation();
195  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
196  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentOfRelation.csv');
197 
198  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
199  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
200  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
201  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
202  }
203 
207  public function ‪modifyBothsOfRelation(): void
208  {
209  parent::modifyBothsOfRelation();
210  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
211  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyBothsOfRelation.csv');
212 
213  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
214  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
215  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
216  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
217  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
218  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
219  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
220  }
221 
225  public function ‪deleteContentOfRelation(): void
226  {
227  parent::deleteContentOfRelation();
228  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
229  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContentOfRelation.csv');
230 
231  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
232  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
233  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
234  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
235  }
236 
240  public function ‪deleteCategoryOfRelation(): void
241  {
242  parent::deleteCategoryOfRelation();
243  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
244  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteCategoryOfRelation.csv');
245 
246  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
247  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
248  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
249  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
250  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
251  }
252 
256  public function ‪copyContentOfRelation(): void
257  {
258  parent::copyContentOfRelation();
259  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
260  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentOfRelation.csv');
261 
262  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
263  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
264  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
265  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
266  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
267  }
268 
272  public function ‪copyCategoryOfRelation(): void
273  {
274  parent::copyCategoryOfRelation();
275  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
276  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyCategoryOfRelation.csv');
277 
278  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
279  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
280  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
281  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
282  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category A (copy 1)'));
283  }
284 
288  public function ‪localizeContentOfRelation(): void
289  {
290  parent::localizeContentOfRelation();
291  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
292  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
293 
294  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
295  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
296  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
297  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
298  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
299  }
300 
304  public function ‪localizeCategoryOfRelation(): void
305  {
306  // Create translated page first
307  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
308  parent::localizeCategoryOfRelation();
309  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
310  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeCategoryOfRelation.csv');
311 
312  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
313  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
314  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
315  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
316  ->setTable(self::TABLE_Category)->setField('title')->setValues('[Translate to Dansk:] Category A', 'Category B'));
317  }
318 
323  {
324  parent::moveContentOfRelationToDifferentPage();
325  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
326  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
327 
328  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
329  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
330  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
331  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
332  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
333  }
334 
338  public function ‪copyPage(): void
339  {
340  parent::copyPage();
341  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
342  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyPage.csv');
343 
344  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId($this->recordIds['newPageId']));
345  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
346  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
347  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
348  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
349  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
350  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
351  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'])->setRecordField('categories')
352  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
353  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
354  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'])->setRecordField('categories')
355  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
356  }
357 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\deleteCategoryRelation
‪deleteCategoryRelation()
Definition: ActionTest.php:57
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:322
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest
Definition: ActionTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\modifyBothsOfRelation
‪modifyBothsOfRelation()
Definition: ActionTest.php:207
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:256
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createCategoryWithContentAndAddRelation
‪createCategoryWithContentAndAddRelation()
Definition: ActionTest.php:166
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll
Definition: ActionTest.php:18
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\modifyCategoryOfRelation
‪modifyCategoryOfRelation()
Definition: ActionTest.php:176
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createCategoryAndAddRelation
‪createCategoryAndAddRelation()
Definition: ActionTest.php:110
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:225
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:288
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\addCategoryRelation
‪addCategoryRelation()
Definition: ActionTest.php:41
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:192
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createCategoryAndCreateRelation
‪createCategoryAndCreateRelation()
Definition: ActionTest.php:146
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\copyCategoryOfRelation
‪copyCategoryOfRelation()
Definition: ActionTest.php:272
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createContentWithCategoryAndAddRelation
‪createContentWithCategoryAndAddRelation()
Definition: ActionTest.php:156
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\copyPage
‪copyPage()
Definition: ActionTest.php:338
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\localizeCategoryOfRelation
‪localizeCategoryOfRelation()
Definition: ActionTest.php:304
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\deleteCategoryOfRelation
‪deleteCategoryOfRelation()
Definition: ActionTest.php:240
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createContentAndCreateRelation
‪createContentAndCreateRelation()
Definition: ActionTest.php:128
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\createContentAndAddRelation
‪createContentAndAddRelation()
Definition: ActionTest.php:92
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany\PublishAll\ActionTest\changeCategoryRelationSorting
‪changeCategoryRelationSorting()
Definition: ActionTest.php:76