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/Regular/Publish/DataSet/';
26 
35  public function createContents()
36  {
37  parent::createContents();
38  $this->actionService->publishRecords(
39  [
40  self::TABLE_Content => [$this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']],
41  ]
42  );
43  $this->assertAssertionDataSet('createContents');
44 
45  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
46  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
47  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
48  }
49 
55  {
56  parent::createContentAndDiscardCreatedContent();
57  // Actually this is not required, since there's nothing to publish... but it's a test case!
58  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId'], false);
59  $this->assertAssertionDataSet('createContentNDiscardCreatedContent');
60 
61  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
62  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
63  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
64  }
65 
71  {
72  parent::createAndCopyContentAndDiscardCopiedContent();
73  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
74  // Actually this is not required, since there's nothing to publish... but it's a test case!
75  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId'], false);
76  $this->assertAssertionDataSet('createNCopyContentNDiscardCopiedContent');
77 
78  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
79  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
80  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
81  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
82  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1 (copy 1)'));
83  }
84 
89  public function modifyContent()
90  {
91  parent::modifyContent();
92  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
93  $this->assertAssertionDataSet('modifyContent');
94 
95  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
96  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
97  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
98  }
99 
104  public function deleteContent()
105  {
106  parent::deleteContent();
107  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
108  $this->assertAssertionDataSet('deleteContent');
109 
110  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
111  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
112  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
113  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
114  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
115  }
116 
122  {
123  parent::deleteLocalizedContentAndDeleteContent();
124  $this->actionService->publishRecords(
125  [
126  self::TABLE_Content => [self::VALUE_ContentIdThird, self::VALUE_ContentIdThirdLocalized],
127  ]
128  );
129  $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
130 
131  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
132  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
133  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
134  }
135 
140  public function copyContent()
141  {
142  parent::copyContent();
143  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
144  $this->assertAssertionDataSet('copyContent');
145 
146  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
147  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
148  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
149  }
150 
155  public function copyContentToLanguage()
156  {
157  parent::copyContentToLanguage();
158  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
159  $this->assertAssertionDataSet('copyContentToLanguage');
160 
161  $this->setUpFrontendRootPage(1, [
162  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
163  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
164  ]);
165  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
166  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
167  ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #3', '[Translate to Dansk:] Regular Element #2'));
168  }
169 
175  {
176  parent::copyContentToLanguageFromNonDefaultLanguage();
177  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
178  $this->assertAssertionDataSet('copyContentToLanguageFromNonDefaultLanguage');
179 
180  $this->setUpFrontendRootPage(1, [
181  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
182  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRendererNoOverlay.ts'
183  ]);
184  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
185  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
186  ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
187  }
188 
193  public function localizeContent()
194  {
195  parent::localizeContent();
196  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
197  $this->assertAssertionDataSet('localizeContent');
198 
199  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
200  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
201  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
202  }
203 
209  {
210  parent::localizeContentFromNonDefaultLanguage();
211  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
212  $this->assertAssertionDataSet('localizeContentFromNonDefaultLanguage');
213 
214  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageIdSecond)->getResponseSections();
215  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
216  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #3'));
217  }
218 
223  public function changeContentSorting()
224  {
225  parent::changeContentSorting();
226  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
227  $this->assertAssertionDataSet('changeContentSorting');
228 
229  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
230  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
231  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
232  }
233 
238  public function moveContentToDifferentPage()
239  {
240  parent::moveContentToDifferentPage();
241  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
242  $this->assertAssertionDataSet('moveContentToDifferentPage');
243 
244  $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
245  $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
246  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
247  $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
248  $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
249  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
250  }
251 
257  {
258  parent::moveContentToDifferentPageAndChangeSorting();
259  $this->actionService->publishRecords(
260  [
261  self::TABLE_Content => [self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond],
262  ]
263  );
264  $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
265 
266  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
267  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
268  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
269  }
270 
279  public function createPage()
280  {
281  parent::createPage();
282  $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
283  $this->assertAssertionDataSet('createPage');
284 
285  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
286  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
287  ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
288  }
289 
294  public function modifyPage()
295  {
296  parent::modifyPage();
297  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
298  $this->assertAssertionDataSet('modifyPage');
299 
300  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
301  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
302  ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
303  }
304 
309  public function deletePage()
310  {
311  parent::deletePage();
312  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
313  $this->assertAssertionDataSet('deletePage');
314 
315  $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
316  $this->assertContains('PageNotFoundException', $response->getError());
317  }
318 
323  public function deleteContentAndPage()
324  {
325  parent::deleteContentAndPage();
326  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
327  $this->assertAssertionDataSet('deleteContentAndPage');
328 
329  $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
330  $this->assertContains('PageNotFoundException', $response->getError());
331  }
332 
337  public function copyPage()
338  {
339  parent::copyPage();
340  $this->actionService->publishRecords(
341  [
342  self::TABLE_Page => [$this->recordIds['newPageId']],
343  self::TABLE_Content => [$this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']],
344  ]
345  );
346  $this->assertAssertionDataSet('copyPage');
347 
348  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
349  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
350  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
351  }
352 
357  public function copyPageFreeMode()
358  {
359  $this->importScenarioDataSet('LivePageFreeModeElements');
360  parent::copyPageFreeMode();
361  $this->actionService->publishRecords(
362  [
363  self::TABLE_Page => [$this->recordIds['newPageId']],
364  self::TABLE_Content => [$this->recordIds['newContentIdTenth'], $this->recordIds['newContentIdTenthLocalized'], $this->recordIds['newContentIdTenthLocalized2']],
365  ]
366  );
367  $this->assertAssertionDataSet('copyPageFreeMode');
368 
369  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
370  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
371  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target'));
372  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
373  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #10'));
374  }
375 
380  public function localizePage()
381  {
382  parent::localizePage();
383  $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
384  $this->assertAssertionDataSet('localizePage');
385 
386  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
387  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
388  ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
389  }
390 
395  public function changePageSorting()
396  {
397  parent::changePageSorting();
398  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
399  $this->assertAssertionDataSet('changePageSorting');
400 
401  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
402  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
403  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
404  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
405  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
406  }
407 
412  public function movePageToDifferentPage()
413  {
414  parent::movePageToDifferentPage();
415  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
416  $this->assertAssertionDataSet('movePageToDifferentPage');
417 
418  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
419  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
420  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
421  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
422  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
423  }
424 
430  {
431  parent::movePageToDifferentPageAndChangeSorting();
432  $this->actionService->publishRecords(
433  [
434  self::TABLE_Page => [self::VALUE_PageId, self::VALUE_PageIdTarget],
435  ]
436  );
437  $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
438 
439  $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
440  $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
441  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
442  $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
443  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
444  $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
445  $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
446  ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
447  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
448  }
449 
457  {
458  parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
459  $this->actionService->publishRecords(
460  [
461  self::TABLE_Page => [self::VALUE_PageIdTarget, $this->recordIds['newPageId']],
462  ]
463  );
464  $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
465 
466  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
467  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
468  ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
469  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
470  }
471 
477  {
478  parent::createPlaceholdersAndDeleteDraftParentPage();
479  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_ParentPageId);
480  $this->assertAssertionDataSet('createPlaceholdersAndDeleteDraftParentPage');
481  }
482 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=true, $frontendUserId=0)
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])