TYPO3 CMS  TYPO3_6-2
ActionTest.php
Go to the documentation of this file.
1 <?php
3 
17 require_once dirname(dirname(__FILE__)) . '/AbstractActionTestCase.php';
18 
23 
27  protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/Select/Publish/DataSet/';
28 
37  public function addElementRelation() {
38  parent::addElementRelation();
39  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
40  $this->assertAssertionDataSet('addElementRelation');
41 
42  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
43  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
44  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
45  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2', 'Element #3'));
46  }
47 
52  public function deleteElementRelation() {
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  parent::changeElementSorting();
72  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
73  $this->assertAssertionDataSet('changeElementSorting');
74 
75  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
76  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
77  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
78  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
79  }
80 
85  public function changeElementRelationSorting() {
86  parent::changeElementRelationSorting();
87  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
88  $this->assertAssertionDataSet('changeElementRelationSorting');
89 
90  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
91  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
92  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
93  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1', 'Element #2'));
94  }
95 
101  parent::createContentAndAddElementRelation();
102  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
103  $this->assertAssertionDataSet('createContentNAddRelation');
104 
105  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
106  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
107  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
108  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
109  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
110  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
111  }
112 
118  parent::createContentAndCreateElementRelation();
119  $this->actionService->publishRecords(
120  array(
121  self::TABLE_Content => array($this->recordIds['newContentId']),
122  self::TABLE_Element => array($this->recordIds['newElementId']),
123  )
124  );
125  $this->assertAssertionDataSet('createContentNCreateRelation');
126 
127  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
128  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
129  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
130  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
131  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField(self::FIELD_ContentElement)
132  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1'));
133  }
134 
139  public function modifyElementOfRelation() {
140  parent::modifyElementOfRelation();
141  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
142  $this->assertAssertionDataSet('modifyElementOfRelation');
143 
144  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
145  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
146  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
147  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
148  }
149 
154  public function modifyContentOfRelation() {
155  parent::modifyContentOfRelation();
156  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
157  $this->assertAssertionDataSet('modifyContentOfRelation');
158 
159  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
160  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
161  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
162  }
163 
168  public function modifyBothSidesOfRelation() {
169  parent::modifyBothSidesOfRelation();
170  $this->actionService->publishRecords(
171  array(
172  self::TABLE_Content => array(self::VALUE_ContentIdFirst),
173  self::TABLE_Element => array(self::VALUE_ElementIdFirst),
174  )
175  );
176  $this->assertAssertionDataSet('modifyBothSidesOfRelation');
177 
178  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
179  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
180  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
181  ->setTable(self::TABLE_Element)->setField('title')->setValues('Testing #1', 'Element #2'));
182  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
183  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
184  }
185 
190  public function deleteContentOfRelation() {
191  parent::deleteContentOfRelation();
192  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
193  $this->assertAssertionDataSet('deleteContentOfRelation');
194 
195  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
196  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
197  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
198  }
199 
204  public function deleteElementOfRelation() {
205  parent::deleteElementOfRelation();
206  $this->actionService->publishRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
207  $this->assertAssertionDataSet('deleteElementOfRelation');
208 
209  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
210  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
211  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
212  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
213  }
214 
219  public function copyContentOfRelation() {
220  parent::copyContentOfRelation();
221  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
222  $this->assertAssertionDataSet('copyContentOfRelation');
223 
224  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
225  // Referenced elements are not copied with the "parent", which is expected and correct
226  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
227  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['copiedContentId'])->setRecordField(self::FIELD_ContentElement)
228  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
229  }
230 
235  public function copyElementOfRelation() {
236  parent::copyElementOfRelation();
237  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['copiedElementId']);
238  $this->assertAssertionDataSet('copyElementOfRelation');
239 
240  $responseSections = $this->getFrontendResponse(self::VALUE_PageId)->getResponseSections();
241  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
242  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
243  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1'));
244  // Referenced elements are not updated at the "parent", which is expected and correct
245  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
246  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
247  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #1 (copy 1)'));
248  }
249 
254  public function localizeContentOfRelation() {
255  parent::localizeContentOfRelation();
256  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
257  $this->assertAssertionDataSet('localizeContentOfRelation');
258 
259  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
260  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
261  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
262  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
263  }
264 
269  public function localizeElementOfRelation() {
270  parent::localizeElementOfRelation();
271  $this->actionService->publishRecord(self::TABLE_Element, $this->recordIds['localizedElementId']);
272  $this->assertAssertionDataSet('localizeElementOfRelation');
273 
274  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
275  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
276  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField(self::FIELD_ContentElement)
277  ->setTable(self::TABLE_Element)->setField('title')->setValues('[Translate to Dansk:] Element #1', 'Element #2'));
278  }
279 
285  parent::moveContentOfRelationToDifferentPage();
286  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
287  $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
288 
289  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseSections();
290  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
291  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField(self::FIELD_ContentElement)
292  ->setTable(self::TABLE_Element)->setField('title')->setValues('Element #2', 'Element #3'));
293  }
294 
295 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=TRUE)