‪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/Select/Publish/DataSet/';
31 
35  protected ‪$assertCleanReferenceIndex = false;
36 
40  public function ‪addElementRelation()
41  {
42  parent::addElementRelation();
43  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
44  $this->‪assertAssertionDataSet('addElementRelation');
45 
46  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
47  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
48  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
49  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
50  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
51  }
52 
56  public function ‪deleteElementRelation()
57  {
58  parent::deleteElementRelation();
59  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
60  $this->‪assertAssertionDataSet('deleteElementRelation');
61 
62  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
63  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
64  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
65  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
66  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
67  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
68  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
69  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
70  }
71 
75  public function ‪changeElementSorting()
76  {
77  parent::changeElementSorting();
78  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
79  $this->‪assertAssertionDataSet('changeElementSorting');
80 
81  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
82  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
83  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
84  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
85  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
86  }
87 
91  public function ‪changeElementRelationSorting()
92  {
93  parent::changeElementRelationSorting();
94  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
95  $this->‪assertAssertionDataSet('changeElementRelationSorting');
96 
97  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
98  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
99  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
100  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
101  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
102  }
103 
107  public function ‪createContentAndAddElementRelation()
108  {
109  parent::createContentAndAddElementRelation();
110  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
111  $this->‪assertAssertionDataSet('createContentNAddRelation');
112 
113  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
114  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
115  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
116  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
117  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
118  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
119  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
120  }
121 
126  {
127  parent::createContentAndCreateElementRelation();
128  $this->actionService->publishRecords([
129  self::TABLE_Content => [$this->recordIds['newContentId']],
130  self::TABLE_Element => [$this->recordIds['newElementId']],
131  ]);
132  $this->‪assertAssertionDataSet('createContentNCreateRelation');
133 
134  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
135  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
136  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
137  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
138  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
139  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
140  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
141  }
142 
146  public function ‪modifyElementOfRelation()
147  {
148  parent::modifyElementOfRelation();
149  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
150  $this->‪assertAssertionDataSet('modifyElementOfRelation');
151 
152  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
153  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
154  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
155  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
156  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
157  }
158 
162  public function ‪modifyContentOfRelation()
163  {
164  parent::modifyContentOfRelation();
165  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
166  $this->‪assertAssertionDataSet('modifyContentOfRelation');
167 
168  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
169  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
170  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
171  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
172  }
173 
177  public function ‪modifyBothSidesOfRelation()
178  {
179  parent::modifyBothSidesOfRelation();
180  $this->actionService->publishRecords([
181  self::TABLE_Content => [self::VALUE_ContentIdFirst],
182  self::TABLE_Element => [self::VALUE_ElementIdFirst],
183  ]);
184  $this->‪assertAssertionDataSet('modifyBothSidesOfRelation');
185 
186  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
187  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
188  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
189  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
190  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
191  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
192  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
193  }
194 
198  public function ‪deleteContentOfRelation()
199  {
200  parent::deleteContentOfRelation();
201  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
202  $this->‪assertAssertionDataSet('deleteContentOfRelation');
203 
204  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
205  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
206  self::assertThat($responseSections, $this->‪getRequestSectionDoesNotHaveRecordConstraint()
207  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
208  }
209 
213  public function ‪deleteElementOfRelation()
214  {
215  parent::deleteElementOfRelation();
216  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
217  $this->‪assertAssertionDataSet('deleteElementOfRelation');
218 
219  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
220  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
221  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
222  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
223  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
224  }
225 
229  public function ‪copyContentOfRelation()
230  {
231  parent::copyContentOfRelation();
232  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
233  $this->‪assertAssertionDataSet('copyContentOfRelation');
234 
235  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
236  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
237  // Referenced elements are not copied with the "parent", which is expected and correct
238  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
239  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
240  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
241  }
242 
246  public function ‪copyElementOfRelation()
247  {
248  parent::copyElementOfRelation();
249  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['copiedElementId']);
250  $this->‪assertAssertionDataSet('copyElementOfRelation');
251 
252  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
253  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
254  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
255  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
256  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
257  // Referenced elements are not updated at the "parent", which is expected and correct
258  self::assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
259  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
260  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
261  }
262 
266  public function ‪localizeContentOfRelation()
267  {
268  parent::localizeContentOfRelation();
269  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
270  $this->‪assertAssertionDataSet('localizeContentOfRelation');
271 
272  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
273  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
274  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
275  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
276  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
277  }
278 
282  public function ‪localizeElementOfRelation()
283  {
284  // Create and publish translated page first
285  $translatedPageResult = $this->actionService->copyRecordToLanguage('pages', self::VALUE_PageId, self::VALUE_LanguageId);
286  $this->actionService->publishRecord('pages', $translatedPageResult['pages'][self::VALUE_PageId]);
287  parent::localizeElementOfRelation();
288  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['localizedElementId']);
289  $this->‪assertAssertionDataSet('localizeElementOfRelation');
290 
291  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId)->withLanguageId(self::VALUE_LanguageId));
292  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
293  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
294  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
295  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
296  }
297 
302  {
303  parent::moveContentOfRelationToDifferentPage();
304  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
305  $this->‪assertAssertionDataSet('moveContentOfRelationToDifferentPage');
306 
307  $response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageIdTarget));
308  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections();
309  self::assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
310  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
311  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
312  }
313 }
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\deleteElementRelation
‪deleteElementRelation()
Definition: ActionTest.php:54
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:289
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\changeElementSorting
‪changeElementSorting()
Definition: ActionTest.php:73
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:305
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: ActionTest.php:144
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: ActionTest.php:105
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish
Definition: ActionTest.php:16
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: ActionTest.php:264
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\copyContentOfRelation
‪copyContentOfRelation()
Definition: ActionTest.php:227
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: ActionTest.php:299
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:313
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\addElementRelation
‪addElementRelation()
Definition: ActionTest.php:38
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: ActionTest.php:175
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest
Definition: ActionTest.php:26
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: ActionTest.php:33
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: ActionTest.php:196
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: ActionTest.php:280
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\copyElementOfRelation
‪copyElementOfRelation()
Definition: ActionTest.php:244
‪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\Select\Publish\ActionTest\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: ActionTest.php:89
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: ActionTest.php:211
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: ActionTest.php:29
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: ActionTest.php:123
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:22
‪TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Select\Publish\ActionTest\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: ActionTest.php:160