‪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/PublishAll/DataSet/';
31 
35  protected ‪$assertCleanReferenceIndex = false;
36 
40  public function ‪modifyContent()
41  {
42  parent::modifyContent();
43  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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->publishWorkspace(self::VALUE_WorkspaceId);
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  parent::localizeContent();
98  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
99  $this->‪assertAssertionDataSet('localizeContent');
100 
101  $response = $this->executeFrontendRequest((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()
115  {
116  parent::changeContentSorting();
117  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
118  $this->‪assertAssertionDataSet('changeContentSorting');
119 
120  $response = $this->executeFrontendRequest((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()
136  {
137  parent::moveContentToDifferentPage();
138  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
139  $this->‪assertAssertionDataSet('moveContentToDifferentPage');
140 
141  $response = $this->executeFrontendRequest((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->executeFrontendRequest((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->publishWorkspace(self::VALUE_WorkspaceId);
164  $this->‪assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
165 
166  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
167  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
168  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
169  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
170  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
171  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
172  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
173  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
174  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
175  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
176  }
177 
185  public function ‪createContentWithFileReference()
186  {
187  parent::createContentWithFileReference();
188  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
189  $this->‪assertAssertionDataSet('createContentWFileReference');
190 
191  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
192  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
193  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
194  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
195  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
196  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
197  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(true));
198  }
199 
203  public function ‪modifyContentWithFileReference()
204  {
205  parent::modifyContentWithFileReference();
206  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
207  $this->‪assertAssertionDataSet('modifyContentWFileReference');
208 
209  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
210  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
211  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
212  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
213  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
214  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
215  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(true));
216  }
217 
221  public function ‪modifyContentAndAddFileReference()
222  {
223  parent::modifyContentAndAddFileReference();
224  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
225  $this->‪assertAssertionDataSet('modifyContentNAddFileReference');
226 
227  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
228  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
229  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
230  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
231  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(true));
232  }
233 
238  {
239  parent::modifyContentAndDeleteFileReference();
240  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
241  $this->‪assertAssertionDataSet('modifyContentNDeleteFileReference');
242 
243  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
244  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
245  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
246  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
247  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(true));
248  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
249  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
250  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
251  }
252 
257  {
258  parent::modifyContentAndDeleteAllFileReference();
259  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
260  $this->‪assertAssertionDataSet('modifyContentNDeleteAllFileReference');
261 
262  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
263  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
264  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
265  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
266  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
267  }
268 
273  {
274  parent::createContentWithFileReferenceAndDeleteFileReference();
275  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
276  $this->‪assertAssertionDataSet('createContentWFileReferenceNDeleteFileReference');
277  // No FE test: Create and delete scenarios have FE coverage, this test is only about DB state.
278  }
279 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContent
‪modifyContent()
Definition: ActionTest.php:38
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\createContentWithFileReference
‪createContentWithFileReference()
Definition: ActionTest.php:183
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: ActionTest.php:133
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: ActionTest.php:254
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\changeContentSorting
‪changeContentSorting()
Definition: ActionTest.php:112
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: ActionTest.php:219
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: ActionTest.php:158
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\localizeContent
‪localizeContent()
Definition: ActionTest.php:91
‪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\PublishAll\ActionTest\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: ActionTest.php:270
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\deleteContent
‪deleteContent()
Definition: ActionTest.php:56
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: ActionTest.php:235
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: ActionTest.php:201
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll
Definition: ActionTest.php:16
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\copyContent
‪copyContent()
Definition: ActionTest.php:73
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\PublishAll\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29