‪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 
42  public function ‪addCategoryRelation(): void
43  {
44  parent::addCategoryRelation();
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 ‪createCategoryAndAddRelation(): void
58  {
59  parent::createCategoryAndAddRelation();
60  $this->assertCSVDataSet(__DIR__ . '/DataSet/createCategoryAndAddRelation.csv');
61 
62  $response = $this->executeFrontendSubRequest((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', 'Category B', 'Testing #1'));
67  }
68 
73  public function ‪deleteCategoryRelation(): void
74  {
75  parent::deleteCategoryRelation();
76  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteCategoryRelation.csv');
77 
78  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
79  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
80  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
81  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
82  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
83  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
84  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
85  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
86  }
87 
92  public function ‪changeCategoryRelationSorting(): void
93  {
94  parent::changeCategoryRelationSorting();
95  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeCategoryRelationSorting.csv');
96 
97  $response = $this->executeFrontendSubRequest((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('categories')
101  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
102  }
103 
108  public function ‪modifyCategoryOfRelation(): void
109  {
110  parent::modifyCategoryOfRelation();
111  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyCategoryOfRelation.csv');
112 
113  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
114  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
115  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
116  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
117  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
118  }
119 
124  public function ‪modifyContentOfRelation(): void
125  {
126  parent::modifyContentOfRelation();
127  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentOfRelation.csv');
128 
129  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
130  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
131  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
132  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
133  }
134 
139  public function ‪modifyBothsOfRelation(): void
140  {
141  parent::modifyBothsOfRelation();
142  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyBothsOfRelation.csv');
143 
144  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
145  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
146  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
147  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
148  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
149  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
150  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
151  }
152 
157  public function ‪deleteContentOfRelation(): void
158  {
159  parent::deleteContentOfRelation();
160  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContentOfRelation.csv');
161 
162  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
163  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
164  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
165  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
166  }
167 
172  public function ‪deleteCategoryOfRelation(): void
173  {
174  parent::deleteCategoryOfRelation();
175  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteCategoryOfRelation.csv');
176 
177  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
178  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
179  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
180  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
181  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
182  }
183 
188  public function ‪copyContentOfRelation(): void
189  {
190  parent::copyContentOfRelation();
191  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentOfRelation.csv');
192 
193  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
194  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
195  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
196  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
197  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
198  }
199 
204  public function ‪copyCategoryOfRelation(): void
205  {
206  parent::copyCategoryOfRelation();
207  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyCategoryOfRelation.csv');
208  }
209 
214  public function ‪copyContentToLanguageOfRelation(): void
215  {
216  parent::copyContentToLanguageOfRelation();
217  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContentToLanguageOfRelation.csv');
218 
219  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
220  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
221  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
222  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
223  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
224  }
225 
230  public function ‪copyCategoryToLanguageOfRelation(): void
231  {
232  parent::copyCategoryToLanguageOfRelation();
233  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyCategoryToLanguageOfRelation.csv');
234  //in this case the translated element is orphaned (no CE with relation to it, and it has no l10n_parent)
235  //so on frontend there is no change.
236  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
237  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
238  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
239  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
240  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
241  }
242 
247  public function ‪localizeContentOfRelation(): void
248  {
249  parent::localizeContentOfRelation();
250  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelation.csv');
251 
252  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
253  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
254  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
255  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
256  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
257  }
258 
264  {
265  parent::localizeContentOfRelationWithLanguageSynchronization();
266  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationWSynchronization.csv');
267 
268  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
269  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
270  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
271  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
272  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
273  }
274 
280  {
281  parent::localizeContentOfRelationAndAddCategoryWithLanguageSynchronization();
282  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentOfRelationNAddCategoryWSynchronization.csv');
283 
284  $response = $this->executeFrontendSubRequest((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_ContentIdLast)->setRecordField('categories')
288  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
289  }
290 
296  {
297  parent::localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization();
298  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContentChainOfRelationNAddCategoryWSynchronization.csv');
299 
300  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageIdSecond));
301  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
302  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
303  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
304  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
305  }
306 
311  public function ‪localizeCategoryOfRelation(): void
312  {
313  // Create translated page first
314  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
315  parent::localizeCategoryOfRelation();
316  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeCategoryOfRelation.csv');
317 
318  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
319  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
320  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
321  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
322  ->setTable(self::TABLE_Category)->setField('title')->setValues('[Translate to Dansk:] Category A', 'Category B'));
323  }
324 
330  {
331  parent::moveContentOfRelationToDifferentPage();
332  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentOfRelationToDifferentPage.csv');
333 
334  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
335  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
336  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
337  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
338  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
339  }
340 
345  public function ‪copyPage(): void
346  {
347  parent::copyPage();
348  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyPage.csv');
349 
350  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId($this->recordIds['newPageId']));
351  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
352  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
353  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
354  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
355  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
356  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
357  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'])->setRecordField('categories')
358  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
359  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
360  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'])->setRecordField('categories')
361  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
362  }
363 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\modifyCategoryOfRelation
‪modifyCategoryOfRelation()
Definition: ActionTest.php:108
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\deleteCategoryRelation
‪deleteCategoryRelation()
Definition: ActionTest.php:73
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyCategoryOfRelation
‪copyCategoryOfRelation()
Definition: ActionTest.php:204
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify
Definition: ActionTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeCategoryOfRelation
‪localizeCategoryOfRelation()
Definition: ActionTest.php:311
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyPage
‪copyPage()
Definition: ActionTest.php:345
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest
Definition: ActionTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization
‪localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization()
Definition: ActionTest.php:295
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:247
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\addCategoryRelation
‪addCategoryRelation()
Definition: ActionTest.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\createCategoryAndAddRelation
‪createCategoryAndAddRelation()
Definition: ActionTest.php:57
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:329
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\modifyBothsOfRelation
‪modifyBothsOfRelation()
Definition: ActionTest.php:139
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: ActionTest.php:214
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\deleteCategoryOfRelation
‪deleteCategoryOfRelation()
Definition: ActionTest.php:172
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:188
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:157
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyCategoryToLanguageOfRelation
‪copyCategoryToLanguageOfRelation()
Definition: ActionTest.php:230
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\changeCategoryRelationSorting
‪changeCategoryRelationSorting()
Definition: ActionTest.php:92
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:124
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentOfRelationWithLanguageSynchronization
‪localizeContentOfRelationWithLanguageSynchronization()
Definition: ActionTest.php:263
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentOfRelationAndAddCategoryWithLanguageSynchronization
‪localizeContentOfRelationAndAddCategoryWithLanguageSynchronization()
Definition: ActionTest.php:279
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\AbstractActionTestCase
Definition: AbstractActionTestCase.php:26