‪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\InternalRequestContext;
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
22 
27 {
31  protected ‪$assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/FAL/Modify/DataSet/';
32 
36  protected ‪$assertCleanReferenceIndex = false;
37 
41  public function ‪modifyContent()
42  {
43  parent::modifyContent();
44  $this->‪assertAssertionDataSet('modifyContent');
45 
46  $response = $this->executeFrontendRequest(
47  (new InternalRequest())->withPageId(self::VALUE_PageId),
48  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
49  );
50  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
51  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
52  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
53  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
54  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
55  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
56  }
57 
61  public function ‪deleteContent()
62  {
63  parent::deleteContent();
64  $this->‪assertAssertionDataSet('deleteContent');
65 
66  $response = $this->executeFrontendRequest(
67  (new InternalRequest())->withPageId(self::VALUE_PageId),
68  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
69  );
70  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
71  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
72  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
73  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
74  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
75  }
76 
80  public function ‪copyContent()
81  {
82  parent::copyContent();
83  $this->‪assertAssertionDataSet('copyContent');
84 
85  $response = $this->executeFrontendRequest(
86  (new InternalRequest())->withPageId(self::VALUE_PageId),
87  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
88  );
89  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
90  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
91  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
92  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
93  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentImage)
94  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
95  }
96 
100  public function ‪localizeContent()
101  {
102  // Create translated page first
103  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
104  parent::localizeContent();
105  $this->‪assertAssertionDataSet('localizeContent');
106 
107  $response = $this->executeFrontendRequest(
108  (new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId),
109  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
110  );
111  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
112  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
113  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
114 
115  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
116  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
117  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('[Translate to Dansk:] This is Kasper', '[Translate to Dansk:] Taken at T3BOARD')->setStrict(true));
118  }
119 
123  public function ‪changeContentSorting()
124  {
125  parent::changeContentSorting();
126  $this->‪assertAssertionDataSet('changeContentSorting');
127 
128  $response = $this->executeFrontendRequest(
129  (new InternalRequest())->withPageId(self::VALUE_PageId),
130  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
131  );
132  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
133  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
134  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
135  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
136  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
137  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD'));
138  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
139  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
140  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
141  }
142 
146  public function ‪moveContentToDifferentPage()
147  {
148  parent::moveContentToDifferentPage();
149  $this->‪assertAssertionDataSet('moveContentToDifferentPage');
150 
151  $response = $this->executeFrontendRequest(
152  (new InternalRequest())->withPageId(self::VALUE_PageId),
153  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
154  );
155  $responseSectionsSource = ResponseContent::fromString((string)$response->getBody())->getSections();
156  self::assertThat($responseSectionsSource, $this->‪getRequestSectionHasRecordConstraint()
157  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
158  self::assertThat($responseSectionsSource, $this->‪getRequestSectionStructureHasRecordConstraint()
159  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
160  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
161 
162  $response = $this->executeFrontendRequest(
163  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
164  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
165  );
166  $responseSectionsTarget = ResponseContent::fromString((string)$response->getBody())->getSections();
167  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionHasRecordConstraint()
168  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
169  self::assertThat($responseSectionsTarget, $this->‪getRequestSectionStructureHasRecordConstraint()
170  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
171  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
172  }
173 
178  {
179  parent::moveContentToDifferentPageAndChangeSorting();
180  $this->‪assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
181 
182  $response = $this->executeFrontendRequest(
183  (new InternalRequest())->withPageId(self::VALUE_PageIdTarget),
184  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
185  );
186  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
187  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
188  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
189  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
190  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentImage)
191  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Kasper', 'T3BOARD')->setStrict(true));
192  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
193  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
194  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper', 'Taken at T3BOARD')->setStrict(true));
195  }
196 
204  public function ‪createContentWithFileReference()
205  {
206  parent::createContentWithFileReference();
207  $this->‪assertAssertionDataSet('createContentWFileReference');
208 
209  $response = $this->executeFrontendRequest(
210  (new InternalRequest())->withPageId(self::VALUE_PageId),
211  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
212  );
213  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
214  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
215  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
216  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
217  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentImage)
218  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Image #1')->setStrict(true));
219  }
220 
224  public function ‪modifyContentWithFileReference()
225  {
226  parent::modifyContentWithFileReference();
227  $this->‪assertAssertionDataSet('modifyContentWFileReference');
228 
229  $response = $this->executeFrontendRequest(
230  (new InternalRequest())->withPageId(self::VALUE_PageId),
231  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
232  );
233  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
234  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
235  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
236  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
237  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
238  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'Image #1')->setStrict(true));
239  }
240 
244  public function ‪modifyContentAndAddFileReference()
245  {
246  parent::modifyContentAndAddFileReference();
247  $this->‪assertAssertionDataSet('modifyContentNAddFileReference');
248 
249  $response = $this->executeFrontendRequest(
250  (new InternalRequest())->withPageId(self::VALUE_PageId),
251  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
252  );
253  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
254  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
255  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
256  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper', 'Image #3')->setStrict(true));
257  }
258 
263  {
264  parent::modifyContentAndDeleteFileReference();
265  $this->‪assertAssertionDataSet('modifyContentNDeleteFileReference');
266 
267  $response = $this->executeFrontendRequest(
268  (new InternalRequest())->withPageId(self::VALUE_PageId),
269  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
270  );
271  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
272  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
273  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
274  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('This is Kasper')->setStrict(true));
275  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
276  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
277  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD'));
278  }
279 
284  {
285  parent::modifyContentAndDeleteAllFileReference();
286  $this->‪assertAssertionDataSet('modifyContentNDeleteAllFileReference');
287 
288  $response = $this->executeFrontendRequest(
289  (new InternalRequest())->withPageId(self::VALUE_PageId),
290  (new InternalRequestContext())->withBackendUserId(self::VALUE_BackendUserId)->withWorkspaceId(self::VALUE_WorkspaceId)
291  );
292  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
293  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
294  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentImage)
295  ->setTable(self::TABLE_FileReference)->setField('title')->setValues('Taken at T3BOARD', 'This is Kasper'));
296  }
297 
302  {
303  parent::createContentWithFileReferenceAndDeleteFileReference();
304  $this->‪assertAssertionDataSet('createContentWFileReferenceNDeleteFileReference');
305  // No FE test: Create and delete scenarios have FE coverage, this test is only about DB state.
306  }
307 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: ActionTest.php:299
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\localizeContent
‪localizeContent()
Definition: ActionTest.php:98
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\createContentWithFileReference
‪createContentWithFileReference()
Definition: ActionTest.php:202
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContent
‪modifyContent()
Definition: ActionTest.php:39
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: ActionTest.php:175
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: ActionTest.php:144
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: ActionTest.php:222
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: ActionTest.php:242
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\copyContent
‪copyContent()
Definition: ActionTest.php:78
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:34
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\deleteContent
‪deleteContent()
Definition: ActionTest.php:59
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:30
‪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\Modify\ActionTest\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: ActionTest.php:281
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: ActionTest.php:260
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest
Definition: ActionTest.php:27
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify\ActionTest\changeContentSorting
‪changeContentSorting()
Definition: ActionTest.php:121
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify
Definition: ActionTest.php:16