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/ManyToMany/Publish/DataSet/';
26 
35  public function addCategoryRelation()
36  {
37  parent::addCategoryRelation();
38  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
39  $this->assertAssertionDataSet('addCategoryRelation');
40 
41  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
42  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
43  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
44  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B', 'Category A.A'));
45  }
46 
51  public function deleteCategoryRelation()
52  {
53  parent::deleteCategoryRelation();
54  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
55  $this->assertAssertionDataSet('deleteCategoryRelation');
56 
57  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
58  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
59  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
60  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
61  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
62  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
63  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C', 'Category A.A'));
64  }
65 
71  {
72  parent::changeCategoryRelationSorting();
73  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
74  $this->assertAssertionDataSet('changeCategoryRelationSorting');
75 
76  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
77  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
78  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
79  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
80  }
81 
86  public function createContentAndAddRelation()
87  {
88  parent::createContentAndAddRelation();
89  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
90  $this->assertAssertionDataSet('createContentNAddRelation');
91 
92  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
93  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
94  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
95  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
96  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
97  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B'));
98  }
99 
105  {
106  parent::createCategoryAndAddRelation();
107  $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['newCategoryId']);
108  $this->assertAssertionDataSet('createCategoryNAddRelation');
109 
110  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
111  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
112  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
113  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
114  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
115  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
116  }
117 
123  {
124  parent::createContentAndCreateRelation();
125  $this->actionService->publishRecords(
126  [
127  self::TABLE_Category => [$this->recordIds['newCategoryId']],
128  self::TABLE_Content => [$this->recordIds['newContentId']],
129  ]
130  );
131  $this->assertAssertionDataSet('createContentNCreateRelation');
132 
133  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
134  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
135  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
136  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
137  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
138  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1'));
139  }
140 
146  {
147  parent::createCategoryAndCreateRelation();
148  $this->actionService->publishRecords(
149  [
150  self::TABLE_Content => [$this->recordIds['newContentId']],
151  self::TABLE_Category => [$this->recordIds['newCategoryId']],
152  ]
153  );
154  $this->actionService->publishWorkspace(self::VALUE_WorkspaceId);
155  $this->assertAssertionDataSet('createCategoryNCreateRelation');
156  }
157 
163  {
164  parent::createContentWithCategoryAndAddRelation();
165  $this->actionService->publishRecords(
166  [
167  self::TABLE_Category => [$this->recordIds['newCategoryId']],
168  self::TABLE_Content => [$this->recordIds['newContentId']],
169  ]
170  );
171  $this->assertAssertionDataSet('createContentWCategoryNAddRelation');
172  }
173 
179  {
180  parent::createCategoryWithContentAndAddRelation();
181  $this->actionService->publishRecords(
182  [
183  self::TABLE_Content => [$this->recordIds['newContentId']],
184  self::TABLE_Category => [$this->recordIds['newCategoryId']],
185  ]
186  );
187  $this->assertAssertionDataSet('createCategoryWContentNAddRelation');
188  }
189 
194  public function modifyCategoryOfRelation()
195  {
196  parent::modifyCategoryOfRelation();
197  $this->actionService->publishRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
198  $this->assertAssertionDataSet('modifyCategoryOfRelation');
199 
200  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
201  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
202  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
203  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
204  }
205 
210  public function modifyContentOfRelation()
211  {
212  parent::modifyContentOfRelation();
213  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
214  $this->assertAssertionDataSet('modifyContentOfRelation');
215 
216  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
217  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
218  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
219  }
220 
225  public function modifyBothsOfRelation()
226  {
227  parent::modifyBothsOfRelation();
228  $this->actionService->publishRecords(
229  [
230  self::TABLE_Content => [self::VALUE_ContentIdFirst],
231  self::TABLE_Category => [self::VALUE_CategoryIdFirst],
232  ]
233  );
234  $this->assertAssertionDataSet('modifyBothsOfRelation');
235 
236  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
237  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
238  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
239  ->setTable(self::TABLE_Category)->setField('title')->setValues('Testing #1', 'Category B'));
240  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
241  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
242  }
243 
248  public function deleteContentOfRelation()
249  {
250  parent::deleteContentOfRelation();
251  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
252  $this->assertAssertionDataSet('deleteContentOfRelation');
253 
254  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
255  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
256  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
257  }
258 
263  public function deleteCategoryOfRelation()
264  {
265  parent::deleteCategoryOfRelation();
266  $this->actionService->publishRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
267  $this->assertAssertionDataSet('deleteCategoryOfRelation');
268 
269  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
270  $this->assertThat($responseSections, $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
271  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
272  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A'));
273  }
274 
279  public function copyContentOfRelation()
280  {
281  parent::copyContentOfRelation();
282  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
283  $this->assertAssertionDataSet('copyContentOfRelation');
284 
285  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
286  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
287  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentId'])->setRecordField('categories')
288  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
289  }
290 
295  public function copyCategoryOfRelation()
296  {
297  parent::copyCategoryOfRelation();
298  $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['newCategoryId']);
299  $this->assertAssertionDataSet('copyCategoryOfRelation');
300 
301  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
302  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
303  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
304  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category A (copy 1)'));
305  }
306 
311  public function localizeContentOfRelation()
312  {
313  parent::localizeContentOfRelation();
314  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
315  $this->assertAssertionDataSet('localizeContentOfRelation');
316 
317  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
318  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
319  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
320  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
321  }
322 
327  public function localizeCategoryOfRelation()
328  {
329  parent::localizeCategoryOfRelation();
330  $this->actionService->publishRecord(self::TABLE_Category, $this->recordIds['localizedCategoryId']);
331  $this->assertAssertionDataSet('localizeCategoryOfRelation');
332 
333  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
334  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
335  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdFirst)->setRecordField('categories')
336  ->setTable(self::TABLE_Category)->setField('title')->setValues('[Translate to Dansk:] Category A', 'Category B'));
337  }
338 
344  {
345  parent::moveContentOfRelationToDifferentPage();
346  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
347  $this->assertAssertionDataSet('moveContentOfRelationToDifferentPage');
348 
349  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
350  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
351  ->setRecordIdentifier(self::TABLE_Content . ':' . self::VALUE_ContentIdLast)->setRecordField('categories')
352  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
353  }
354 
359  public function copyPage()
360  {
361  parent::copyPage();
362  $this->actionService->publishRecords(
363  [
364  self::TABLE_Page => [$this->recordIds['newPageId']],
365  self::TABLE_Content => [$this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']],
366  ]
367  );
368  $this->assertAssertionDataSet('copyPage');
369 
370  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'])->getResponseSections();
371  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
372  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
373  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
374  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
375  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
376  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdFirst'])->setRecordField('categories')
377  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category A', 'Category B'));
378  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
379  ->setRecordIdentifier(self::TABLE_Content . ':' . $this->recordIds['newContentIdLast'])->setRecordField('categories')
380  ->setTable(self::TABLE_Category)->setField('title')->setValues('Category B', 'Category C'));
381  }
382 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=true, $frontendUserId=0)