TYPO3 CMS  TYPO3_7-6
ActionTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Select/Publish/DataSet/';
26 
35  public function addElementRelation()
36  {
37  parent::addElementRelation();
38  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
39  $this->assertAssertionDataSet('addElementRelation');
40 
41  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
42  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
43  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
44  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
45  }
46 
51  public function deleteElementRelation()
52  {
53  parent::deleteElementRelation();
54  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
55  $this->assertAssertionDataSet('deleteElementRelation');
56 
57  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
58  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
59  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
60  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
61  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
62  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
63  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
64  }
65 
70  public function changeElementSorting()
71  {
72  parent::changeElementSorting();
73  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
74  $this->assertAssertionDataSet('changeElementSorting');
75 
76  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
77  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
78  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
79  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
80  }
81 
86  public function changeElementRelationSorting()
87  {
88  parent::changeElementRelationSorting();
89  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
90  $this->assertAssertionDataSet('changeElementRelationSorting');
91 
92  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
93  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
94  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
95  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
96  }
97 
103  {
104  parent::createContentAndAddElementRelation();
105  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
106  $this->assertAssertionDataSet('createContentNAddRelation');
107 
108  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
109  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
110  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
111  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
112  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
113  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
114  }
115 
121  {
122  parent::createContentAndCreateElementRelation();
123  $this->actionService->publishRecords(
124  [
125  self::TABLE_Content => [$this->recordIds['newContentId']],
126  self::TABLE_Element => [$this->recordIds['newElementId']],
127  ]
128  );
129  $this->assertAssertionDataSet('createContentNCreateRelation');
130 
131  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
132  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
133  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
134  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
135  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
136  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
137  }
138 
143  public function modifyElementOfRelation()
144  {
145  parent::modifyElementOfRelation();
146  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
147  $this->assertAssertionDataSet('modifyElementOfRelation');
148 
149  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
150  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
151  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
152  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
153  }
154 
159  public function modifyContentOfRelation()
160  {
161  parent::modifyContentOfRelation();
162  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
163  $this->assertAssertionDataSet('modifyContentOfRelation');
164 
165  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
166  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
167  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
168  }
169 
174  public function modifyBothSidesOfRelation()
175  {
176  parent::modifyBothSidesOfRelation();
177  $this->actionService->publishRecords(
178  [
179  self::TABLE_Content => [self::VALUE_ContentIdFirst],
180  self::TABLE_Element => [self::VALUE_ElementIdFirst],
181  ]
182  );
183  $this->assertAssertionDataSet('modifyBothSidesOfRelation');
184 
185  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
186  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
187  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
188  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
189  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
190  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
191  }
192 
197  public function deleteContentOfRelation()
198  {
199  parent::deleteContentOfRelation();
200  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
201  $this->assertAssertionDataSet('deleteContentOfRelation');
202 
203  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
204  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
205  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
206  }
207 
212  public function deleteElementOfRelation()
213  {
214  parent::deleteElementOfRelation();
215  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
216  $this->assertAssertionDataSet('deleteElementOfRelation');
217 
218  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
219  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
220  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
221  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
222  }
223 
228  public function copyContentOfRelation()
229  {
230  parent::copyContentOfRelation();
231  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
232  $this->assertAssertionDataSet('copyContentOfRelation');
233 
234  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
235  // Referenced elements are not copied with the "parent", which is expected and correct
236  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
237  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
238  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
239  }
240 
245  public function copyElementOfRelation()
246  {
247  parent::copyElementOfRelation();
248  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['copiedElementId']);
249  $this->assertAssertionDataSet('copyElementOfRelation');
250 
251  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
252  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
253  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
254  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
255  // Referenced elements are not updated at the "parent", which is expected and correct
256  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
257  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
258  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
259  }
260 
265  public function localizeContentOfRelation()
266  {
267  parent::localizeContentOfRelation();
268  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
269  $this->assertAssertionDataSet('localizeContentOfRelation');
270 
271  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
272  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
273  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
274  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
275  }
276 
281  public function localizeElementOfRelation()
282  {
283  parent::localizeElementOfRelation();
284  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['localizedElementId']);
285  $this->assertAssertionDataSet('localizeElementOfRelation');
286 
287  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
288  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
289  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
290  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
291  }
292 
298  {
299  parent::moveContentOfRelationToDifferentPage();
300  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
301  $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
302 
303  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
304  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
305  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
306  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
307  }
308 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=true, $frontendUserId=0)