‪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 ‪modifyContent(): void
42  {
43  parent::modifyContent();
44  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
45  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContent.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->‪getRequestSectionHasRecordConstraint()
50  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
51  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
52  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
53  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
54  }
55 
59  public function ‪deleteContent(): void
60  {
61  parent::deleteContent();
62  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
63  $this->assertCSVDataSet(__DIR__ . '/DataSet/deleteContent.csv');
64 
65  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
66  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
67  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
68  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
69  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
70  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
71  }
72 
76  public function ‪copyContent(): void
77  {
78  parent::copyContent();
79  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
80  $this->assertCSVDataSet(__DIR__ . '/DataSet/copyContent.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->‪getRequestSectionHasRecordConstraint()
85  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
86  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
87  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentImage)
88  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
89  }
90 
94  public function ‪localizeContent(): void
95  {
96  parent::localizeContent();
97  $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['localizedPageId']);
98  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
99  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContent.csv');
100 
101  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
102  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
103  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
104  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
105 
106  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
107  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
108  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('[Translate to Dansk:] This is Kasper', '[Translate to Dansk:] Taken at T3BOARD')->setStrict(true));
109  }
110 
114  public function ‪changeContentSorting(): void
115  {
116  parent::changeContentSorting();
117  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
118  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeContentSorting.csv');
119 
120  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
121  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
122  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
123  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
124  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
125  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
126  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
127  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
128  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
129  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
130  }
131 
135  public function ‪moveContentToDifferentPage(): void
136  {
137  parent::moveContentToDifferentPage();
138  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
139  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentToDifferentPage.csv');
140 
141  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
142  $responseSectionsSource = ResponseContent::fromString((string)$response->getBody())->getSections();
143  self::assertThat($responseSectionsSource, $this->‪getRequestSectionHasRecordConstraint()
144  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
145  self::assertThat($responseSectionsSource, $this->‪getRequestSectionStructureHasRecordConstraint()
146  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
147  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
148  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
149  $responseSectionsTarget = ResponseContent::fromString((string)$response->getBody())->getSections();
150  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionHasRecordConstraint()
151  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
152  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionStructureHasRecordConstraint()
153  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
154  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
155  }
156 
161  {
162  parent::moveContentToDifferentPageAndChangeSorting();
163  $this->actionService->publishRecords(
164  [
165  self::TABLE_Content => [self::VALUE_ContentIdFirst, self::VALUE_ContentIdLast],
166  ]
167  );
168  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentToDifferentPageNChangeSorting.csv');
169 
170  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
171  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
172  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
173  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
174  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
175  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
176  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
177  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
178  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
179  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
180  }
181 
189  public function ‪createContentWithFileReference(): void
190  {
191  parent::createContentWithFileReference();
192  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
193  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentWFileReference.csv');
194 
195  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
196  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
197  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
198  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
199  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
200  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
201  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(true));
202  }
203 
207  public function ‪modifyContentWithFileReference(): void
208  {
209  parent::modifyContentWithFileReference();
210  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
211  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentWFileReference.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->‪getRequestSectionHasRecordConstraint()
216  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
217  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
218  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
219  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(true));
220  }
221 
225  public function ‪modifyContentAndAddFileReference(): void
226  {
227  parent::modifyContentAndAddFileReference();
228  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
229  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentNAddFileReference.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->‪getRequestSectionStructureHasRecordConstraint()
234  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
235  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(true));
236  }
237 
242  {
243  parent::modifyContentAndDeleteFileReference();
244  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
245  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentNDeleteFileReference.csv');
246 
247  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
248  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
249  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
250  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
251  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(true));
252  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
253  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
254  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
255  }
256 
261  {
262  parent::modifyContentAndDeleteAllFileReference();
263  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
264  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentNDeleteAllFileReference.csv');
265 
266  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
267  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
268  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
269  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
270  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
271  }
272 
277  {
278  parent::createContentWithFileReferenceAndDeleteFileReference();
279  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
280  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentWFileReferenceNDeleteFileReference.csv');
281  // No FE test: Create and delete scenarios have FE coverage, this test is only about DB state.
282  }
283 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: ActionTest.php:160
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\createContentWithFileReference
‪createContentWithFileReference()
Definition: ActionTest.php:189
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish
Definition: ActionTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\copyContent
‪copyContent()
Definition: ActionTest.php:76
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\localizeContent
‪localizeContent()
Definition: ActionTest.php:94
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: ActionTest.php:225
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: ActionTest.php:276
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: ActionTest.php:260
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\deleteContent
‪deleteContent()
Definition: ActionTest.php:59
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContent
‪modifyContent()
Definition: ActionTest.php:41
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: ActionTest.php:207
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: ActionTest.php:241
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: ActionTest.php:135
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest\changeContentSorting
‪changeContentSorting()
Definition: ActionTest.php:114
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Publish\ActionTest
Definition: ActionTest.php:28