‪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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
98  $this->assertCSVDataSet(__DIR__ . '/DataSet/localizeContent.csv');
99 
100  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
101  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
102  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
103  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
104 
105  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
106  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
107  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('[Translate to Dansk:] This is Kasper', '[Translate to Dansk:] Taken at T3BOARD')->setStrict(true));
108  }
109 
113  public function ‪changeContentSorting(): void
114  {
115  parent::changeContentSorting();
116  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
117  $this->assertCSVDataSet(__DIR__ . '/DataSet/changeContentSorting.csv');
118 
119  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
120  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
121  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
122  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
123  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
124  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
125  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
126  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
127  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
128  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
129  }
130 
134  public function ‪moveContentToDifferentPage(): void
135  {
136  parent::moveContentToDifferentPage();
137  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
138  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentToDifferentPage.csv');
139 
140  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
141  $responseSectionsSource = ResponseContent::fromString((string)$response->getBody())->getSections();
142  self::assertThat($responseSectionsSource, $this->‪getRequestSectionHasRecordConstraint()
143  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
144  self::assertThat($responseSectionsSource, $this->‪getRequestSectionStructureHasRecordConstraint()
145  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
146  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
147  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
148  $responseSectionsTarget = ResponseContent::fromString((string)$response->getBody())->getSections();
149  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionHasRecordConstraint()
150  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
151  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionStructureHasRecordConstraint()
152  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
153  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
154  }
155 
160  {
161  parent::moveContentToDifferentPageAndChangeSorting();
162  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
163  $this->assertCSVDataSet(__DIR__ . '/DataSet/moveContentToDifferentPageNChangeSorting.csv');
164 
165  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
166  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
167  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
168  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
169  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
170  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
171  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
172  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
173  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
174  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
175  }
176 
184  public function ‪createContentWithFileReference(): void
185  {
186  parent::createContentWithFileReference();
187  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
188  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentWFileReference.csv');
189 
190  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
191  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
192  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
193  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
194  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
195  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
196  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(true));
197  }
198 
202  public function ‪modifyContentWithFileReference(): void
203  {
204  parent::modifyContentWithFileReference();
205  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
206  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentWFileReference.csv');
207 
208  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
209  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
210  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
211  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
212  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
213  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
214  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(true));
215  }
216 
220  public function ‪modifyContentAndAddFileReference(): void
221  {
222  parent::modifyContentAndAddFileReference();
223  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
224  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentNAddFileReference.csv');
225 
226  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
227  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
228  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
229  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
230  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(true));
231  }
232 
237  {
238  parent::modifyContentAndDeleteFileReference();
239  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
240  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentNDeleteFileReference.csv');
241 
242  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
243  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
244  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
245  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
246  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(true));
247  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
248  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
249  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
250  }
251 
256  {
257  parent::modifyContentAndDeleteAllFileReference();
258  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
259  $this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContentNDeleteAllFileReference.csv');
260 
261  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
262  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
263  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
264  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
265  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
266  }
267 
272  {
273  parent::createContentWithFileReferenceAndDeleteFileReference();
274  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
275  $this->assertCSVDataSet(__DIR__ . '/DataSet/createContentWFileReferenceNDeleteFileReference.csv');
276  // No FE test: Create and delete scenarios have FE coverage, this test is only about DB state.
277  }
278 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContent
‪modifyContent()
Definition: ActionTest.php:41
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\createContentWithFileReference
‪createContentWithFileReference()
Definition: ActionTest.php:184
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: ActionTest.php:134
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:261
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: ActionTest.php:255
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\changeContentSorting
‪changeContentSorting()
Definition: ActionTest.php:113
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\verifyCleanReferenceIndex
‪verifyCleanReferenceIndex()
Definition: ActionTest.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:269
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: ActionTest.php:220
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest
Definition: ActionTest.php:28
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: ActionTest.php:159
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\localizeContent
‪localizeContent()
Definition: ActionTest.php:94
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:253
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: ActionTest.php:271
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\deleteContent
‪deleteContent()
Definition: ActionTest.php:59
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: ActionTest.php:236
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: ActionTest.php:202
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll
Definition: ActionTest.php:18
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\copyContent
‪copyContent()
Definition: ActionTest.php:76