‪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/FAL/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 ‪modifyContent()
46  {
47  parent::modifyContent();
48  $this->‪assertAssertionDataSet('modifyContent');
49 
50  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
51  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
52  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
53  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
54  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
55  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
56  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
57  }
58 
63  public function ‪deleteContent()
64  {
65  parent::deleteContent();
66  $this->‪assertAssertionDataSet('deleteContent');
67 
68  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
69  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
70  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
71  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
72  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
73  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
74  }
75 
80  public function ‪copyContent()
81  {
82  parent::copyContent();
83  $this->‪assertAssertionDataSet('copyContent');
84 
85  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
86  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
87  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
88  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
89  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
90  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentImage)
91  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
92  }
93 
98  public function ‪copyContentToLanguage()
99  {
100  // Create translated page first
101  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
102  parent::copyContentToLanguage();
103  $this->‪assertAssertionDataSet('copyContentToLanguage');
104 
105  $languageConfiguration = ‪$this->siteLanguageConfiguration;
106  $languageConfiguration[1]['fallbackType'] = 'free';
107  $this->‪setUpFrontendSite(1, $languageConfiguration);
108  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
109  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
110  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
111  ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #2'));
112 
113  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
114  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['localizedContentId'])->setRecordField(self::FIELD_ContentImage)
115  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('[Translate to Dansk:] This is Kasper', '[Translate to Dansk:] Taken at T3BOARD'));
116  }
117 
122  public function ‪localizeContent()
123  {
124  // Create translated page first
125  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
126  parent::localizeContent();
127  $this->‪assertAssertionDataSet('localizeContent');
128 
129  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
130  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
131  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
132  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
133 
134  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
135  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
136  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('[Translate to Dansk:] This is Kasper', '[Translate to Dansk:] Taken at T3BOARD'));
137  }
138 
143  public function ‪changeContentSorting()
144  {
145  parent::changeContentSorting();
146  $this->‪assertAssertionDataSet('changeContentSorting');
147 
148  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
149  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
150  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
151  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
152  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
153  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
154  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
155  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
156  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
157  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
158  }
159 
164  public function ‪moveContentToDifferentPage()
165  {
166  parent::moveContentToDifferentPage();
167  $this->‪assertAssertionDataSet('moveContentToDifferentPage');
168 
169  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
170  $responseSectionsSource = ResponseContent::fromString((string)$response->getBody())->getSections();
171  self::assertThat($responseSectionsSource, $this->‪getRequestSectionHasRecordConstraint()
172  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
173  self::assertThat($responseSectionsSource, $this->‪getRequestSectionStructureHasRecordConstraint()
174  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
175  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
176  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
177  $responseSectionsTarget = ResponseContent::fromString((string)$response->getBody())->getSections();
178  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionHasRecordConstraint()
179  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
180  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionStructureHasRecordConstraint()
181  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
182  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
183  }
184 
190  {
191  parent::moveContentToDifferentPageAndChangeSorting();
192  $this->‪assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
193 
194  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
195  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
196  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
197  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
198  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
199  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
200  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
201  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
202  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
203  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD'));
204  }
205 
214  public function ‪createContentWithFileReference()
215  {
216  parent::createContentWithFileReference();
217  $this->‪assertAssertionDataSet('createContentWFileReference');
218 
219  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
220  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
221  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
222  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
223  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
224  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
225  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1'));
226  }
227 
232  public function ‪modifyContentWithFileReference()
233  {
234  parent::modifyContentWithFileReference();
235  $this->‪assertAssertionDataSet('modifyContentWFileReference');
236 
237  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
238  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
239  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
240  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
241  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
242  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
243  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1'));
244  }
245 
250  public function ‪modifyContentAndAddFileReference()
251  {
252  parent::modifyContentAndAddFileReference();
253  $this->‪assertAssertionDataSet('modifyContentNAddFileReference');
254 
255  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
256  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
257  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
258  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
259  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3'));
260  }
261 
267  {
268  parent::modifyContentAndDeleteFileReference();
269  $this->‪assertAssertionDataSet('modifyContentNDeleteFileReference');
270 
271  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
272  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
273  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
274  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
275  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper'));
276  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
277  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
278  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
279  }
280 
286  {
287  parent::modifyContentAndDeleteAllFileReference();
288  $this->‪assertAssertionDataSet('modifyContentNDeleteAllFileReference');
289 
290  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
291  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
292  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
293  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
294  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
295  }
296 
301  {
302  parent::createContentWithFileReferenceAndDeleteFileReference();
303  $this->‪assertAssertionDataSet('createContentWFileReferenceNDeleteFileReference');
304  // No FE test: Create and delete scenarios have FE coverage, this test is only about DB state.
305  }
306 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:143
‪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\FAL\Modify\ActionTest\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: ActionTest.php:249
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\createContentWithFileReference
‪createContentWithFileReference()
Definition: ActionTest.php:213
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\copyContentToLanguage
‪copyContentToLanguage()
Definition: ActionTest.php:97
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\deleteContent
‪deleteContent()
Definition: ActionTest.php:62
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: ActionTest.php:265
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify
Definition: ActionTest.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: ActionTest.php:299
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: ActionTest.php:188
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: ActionTest.php:284
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\copyContent
‪copyContent()
Definition: ActionTest.php:79
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\changeContentSorting
‪changeContentSorting()
Definition: ActionTest.php:142
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: ActionTest.php:163
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:34
‪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\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\$siteLanguageConfiguration
‪array $siteLanguageConfiguration
Definition: AbstractDataHandlerActionTestCase.php:86
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContent
‪modifyContent()
Definition: ActionTest.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\localizeContent
‪localizeContent()
Definition: ActionTest.php:121
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: ActionTest.php:231