‪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/core/Tests/Functional/DataHandling/ManyToMany/Modify/DataSet/';
31 
35  public function ‪verifyCleanReferenceIndex()
36  {
37  // The test verifies the imported data set has a clean reference index by the check in tearDown()
38  self::assertTrue(true);
39  }
40 
45  public function ‪addCategoryRelation()
46  {
47  parent::addCategoryRelation();
48  $this->‪assertAssertionDataSet('addCategoryRelation');
49 
50  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
51  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
52  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
53  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
54  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B', 'Category A.A'));
55  }
56 
61  public function ‪deleteCategoryRelation()
62  {
63  parent::deleteCategoryRelation();
64  $this->‪assertAssertionDataSet('deleteCategoryRelation');
65 
66  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
67  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
68  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
69  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
70  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
71  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
72  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
73  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
74  }
75 
80  public function ‪changeCategoryRelationSorting()
81  {
82  parent::changeCategoryRelationSorting();
83  $this->‪assertAssertionDataSet('changeCategoryRelationSorting');
84 
85  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
86  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
87  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
88  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
89  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
90  }
91 
96  public function ‪modifyCategoryOfRelation()
97  {
98  parent::modifyCategoryOfRelation();
99  $this->‪assertAssertionDataSet('modifyCategoryOfRelation');
100 
101  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
102  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
103  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
104  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
105  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
106  }
107 
112  public function ‪modifyContentOfRelation()
113  {
114  parent::modifyContentOfRelation();
115  $this->‪assertAssertionDataSet('modifyContentOfRelation');
116 
117  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
118  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
119  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
120  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
121  }
122 
127  public function ‪modifyBothsOfRelation()
128  {
129  parent::modifyBothsOfRelation();
130  $this->‪assertAssertionDataSet('modifyBothsOfRelation');
131 
132  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
133  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
134  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
135  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
136  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
137  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
138  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
139  }
140 
145  public function ‪deleteContentOfRelation()
146  {
147  parent::deleteContentOfRelation();
148  $this->‪assertAssertionDataSet('deleteContentOfRelation');
149 
150  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
151  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
152  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
153  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
154  }
155 
160  public function ‪deleteCategoryOfRelation()
161  {
162  parent::deleteCategoryOfRelation();
163  $this->‪assertAssertionDataSet('deleteCategoryOfRelation');
164 
165  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
166  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
167  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
168  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
169  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
170  }
171 
176  public function ‪copyContentOfRelation()
177  {
178  parent::copyContentOfRelation();
179  $this->‪assertAssertionDataSet('copyContentOfRelation');
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 . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
185  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
186  }
187 
192  public function ‪copyCategoryOfRelation()
193  {
194  parent::copyCategoryOfRelation();
195  $this->‪assertAssertionDataSet('copyCategoryOfRelation');
196 
197  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
198  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
199  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
200  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
201  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category A (copy 1)'));
202  }
203 
208  public function ‪copyContentToLanguageOfRelation()
209  {
210  parent::copyContentToLanguageOfRelation();
211  $this->‪assertAssertionDataSet('copyContentToLanguageOfRelation');
212 
213  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
214  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
215  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
216  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
217  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
218  }
219 
224  public function ‪copyCategoryToLanguageOfRelation()
225  {
226  parent::copyCategoryToLanguageOfRelation();
227  $this->‪assertAssertionDataSet('copyCategoryToLanguageOfRelation');
228  //in this case the translated element is orphaned (no CE with relation to it, and it has no l10n_parent)
229  //so on frontend there is no change.
230  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
231  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
232  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
233  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
234  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
235  }
236 
241  public function ‪localizeContentOfRelation()
242  {
243  parent::localizeContentOfRelation();
244  $this->‪assertAssertionDataSet('localizeContentOfRelation');
245 
246  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
247  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
248  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
249  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
250  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
251  }
252 
258  {
259  parent::localizeContentOfRelationWithLanguageSynchronization();
260  $this->‪assertAssertionDataSet('localizeContentOfRelationWSynchronization');
261 
262  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
263  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
264  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
265  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
266  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
267  }
268 
274  {
275  parent::localizeContentOfRelationAndAddCategoryWithLanguageSynchronization();
276  $this->‪assertAssertionDataSet('localizeContentOfRelationNAddCategoryWSynchronization');
277 
278  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
279  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
280  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
281  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
282  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
283  }
284 
290  {
291  parent::localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization();
292  $this->‪assertAssertionDataSet('localizeContentChainOfRelationNAddCategoryWSynchronization');
293 
294  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageIdSecond));
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', 'Category A.A'));
299  }
300 
305  public function ‪localizeCategoryOfRelation()
306  {
307  // Create translated page first
308  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
309  parent::localizeCategoryOfRelation();
310  $this->‪assertAssertionDataSet('localizeCategoryOfRelation');
311 
312  $response = $this->executeFrontendRequest((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 
324  {
325  parent::moveContentOfRelationToDifferentPage();
326  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
327 
328  $response = $this->executeFrontendRequest((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 
339  public function ‪copyPage()
340  {
341  parent::copyPage();
342  $this->‪assertAssertionDataSet('copyPage');
343 
344  $response = $this->executeFrontendRequest((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\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\modifyCategoryOfRelation
‪modifyCategoryOfRelation()
Definition: ActionTest.php:95
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\deleteCategoryRelation
‪deleteCategoryRelation()
Definition: ActionTest.php:60
‪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\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyCategoryOfRelation
‪copyCategoryOfRelation()
Definition: ActionTest.php:191
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify
Definition: ActionTest.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeCategoryOfRelation
‪localizeCategoryOfRelation()
Definition: ActionTest.php:304
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyPage
‪copyPage()
Definition: ActionTest.php:338
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization
‪localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization()
Definition: ActionTest.php:288
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:240
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\addCategoryRelation
‪addCategoryRelation()
Definition: ActionTest.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:322
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\modifyBothsOfRelation
‪modifyBothsOfRelation()
Definition: ActionTest.php:126
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: ActionTest.php:207
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\deleteCategoryOfRelation
‪deleteCategoryOfRelation()
Definition: ActionTest.php:159
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\assertAssertionDataSet
‪assertAssertionDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:208
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:175
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:297
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:144
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\copyCategoryToLanguageOfRelation
‪copyCategoryToLanguageOfRelation()
Definition: ActionTest.php:223
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\changeCategoryRelationSorting
‪changeCategoryRelationSorting()
Definition: ActionTest.php:79
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:111
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentOfRelationWithLanguageSynchronization
‪localizeContentOfRelationWithLanguageSynchronization()
Definition: ActionTest.php:256
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\Modify\ActionTest\localizeContentOfRelationAndAddCategoryWithLanguageSynchronization
‪localizeContentOfRelationAndAddCategoryWithLanguageSynchronization()
Definition: ActionTest.php:272
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24