‪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/FAL/Publish/DataSet/';
31 
35  protected ‪$assertCleanReferenceIndex = false;
36 
40  public function ‪modifyContent()
41  {
42  parent::modifyContent();
43  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
44  $this->‪assertAssertionDataSet('modifyContent');
45 
46  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
47  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
48  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
49  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
50  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
51  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
52  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
53  }
54 
58  public function ‪deleteContent()
59  {
60  parent::deleteContent();
61  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
62  $this->‪assertAssertionDataSet('deleteContent');
63 
64  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
65  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
66  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
67  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
68  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
69  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
70  }
71 
75  public function ‪copyContent()
76  {
77  parent::copyContent();
78  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
79  $this->‪assertAssertionDataSet('copyContent');
80 
81  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
82  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
83  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
84  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
85  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
86  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentImage)
87  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
88  }
89 
93  public function ‪localizeContent()
94  {
95  // Create and publish translated page first
96  $translatedPageResult = $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
97  $this->actionService->publishRecord(self::TABLE_Page, $translatedPageResult[self::TABLE_Page][self::VALUE_PageId]);
98  parent::localizeContent();
99  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
100  $this->‪assertAssertionDataSet('localizeContent');
101 
102  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
103  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
104  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
105  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
106 
107  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
108  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
109  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('[Translate to Dansk:] This is Kasper', '[Translate to Dansk:] Taken at T3BOARD')->setStrict(true));
110  }
111 
115  public function ‪changeContentSorting()
116  {
117  parent::changeContentSorting();
118  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
119  $this->‪assertAssertionDataSet('changeContentSorting');
120 
121  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
122  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
123  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
124  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
125  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
126  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
127  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
128  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
129  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
130  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
131  }
132 
136  public function ‪moveContentToDifferentPage()
137  {
138  parent::moveContentToDifferentPage();
139  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
140  $this->‪assertAssertionDataSet('moveContentToDifferentPage');
141 
142  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
143  $responseSectionsSource = ResponseContent::fromString((string)$response->getBody())->getSections();
144  self::assertThat($responseSectionsSource, $this->‪getRequestSectionHasRecordConstraint()
145  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
146  self::assertThat($responseSectionsSource, $this->‪getRequestSectionStructureHasRecordConstraint()
147  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
148  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
149  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
150  $responseSectionsTarget = ResponseContent::fromString((string)$response->getBody())->getSections();
151  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionHasRecordConstraint()
152  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
153  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionStructureHasRecordConstraint()
154  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
155  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
156  }
157 
162  {
163  parent::moveContentToDifferentPageAndChangeSorting();
164  $this->actionService->publishRecords(
165  [
166  self::TABLE_Content => [self::VALUE_ContentIdFirst, self::VALUE_ContentIdLast],
167  ]
168  );
169  $this->‪assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
170 
171  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
172  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
173  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
174  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
175  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
176  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
177  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
178  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
179  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
180  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
181  }
182 
190  public function ‪createContentWithFileReference()
191  {
192  parent::createContentWithFileReference();
193  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
194  $this->‪assertAssertionDataSet('createContentWFileReference');
195 
196  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
197  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
198  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
199  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
200  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
201  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
202  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(true));
203  }
204 
208  public function ‪modifyContentWithFileReference()
209  {
210  parent::modifyContentWithFileReference();
211  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
212  $this->‪assertAssertionDataSet('modifyContentWFileReference');
213 
214  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
215  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
216  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
217  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
218  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
219  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
220  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(true));
221  }
222 
226  public function ‪modifyContentAndAddFileReference()
227  {
228  parent::modifyContentAndAddFileReference();
229  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
230  $this->‪assertAssertionDataSet('modifyContentNAddFileReference');
231 
232  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
233  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
234  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
235  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
236  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(true));
237  }
238 
243  {
244  parent::modifyContentAndDeleteFileReference();
245  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
246  $this->‪assertAssertionDataSet('modifyContentNDeleteFileReference');
247 
248  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
249  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
250  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
251  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
252  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(true));
253  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
254  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
255  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
256  }
257 
262  {
263  parent::modifyContentAndDeleteAllFileReference();
264  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
265  $this->‪assertAssertionDataSet('modifyContentNDeleteAllFileReference');
266 
267  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
268  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
269  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
270  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
271  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
272  }
273 
278  {
279  parent::createContentWithFileReferenceAndDeleteFileReference();
280  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
281  $this->‪assertAssertionDataSet('createContentWFileReferenceNDeleteFileReference');
282  // No FE test: Create and delete scenarios have FE coverage, this test is only about DB state.
283  }
284 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: ActionTest.php:159
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\createContentWithFileReference
‪createContentWithFileReference()
Definition: ActionTest.php:188
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish
Definition: ActionTest.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\copyContent
‪copyContent()
Definition: ActionTest.php:73
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\localizeContent
‪localizeContent()
Definition: ActionTest.php:91
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: ActionTest.php:224
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: ActionTest.php:275
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: ActionTest.php:259
‪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\FAL\Publish\ActionTest\deleteContent
‪deleteContent()
Definition: ActionTest.php:56
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContent
‪modifyContent()
Definition: ActionTest.php:38
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: ActionTest.php:206
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: ActionTest.php:240
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: ActionTest.php:134
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\changeContentSorting
‪changeContentSorting()
Definition: ActionTest.php:113
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest
Definition: ActionTest.php:26