TYPO3  7.6
Regular/Publish/ActionTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\Regular\Publish;
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  array(
40  self::TABLE_Content => array($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  array(
126  self::TABLE_Content => array(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 localizeContent()
156  {
157  parent::localizeContent();
158  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
159  $this->assertAssertionDataSet('localizeContent');
160 
161  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
162  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
163  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
164  }
165 
170  public function changeContentSorting()
171  {
172  parent::changeContentSorting();
173  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
174  $this->assertAssertionDataSet('changeContentSorting');
175 
176  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
177  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
178  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
179  }
180 
185  public function moveContentToDifferentPage()
186  {
187  parent::moveContentToDifferentPage();
188  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
189  $this->assertAssertionDataSet('moveContentToDifferentPage');
190 
191  $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
192  $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
193  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
194  $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
195  $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
196  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
197  }
198 
204  {
205  parent::moveContentToDifferentPageAndChangeSorting();
206  $this->actionService->publishRecords(
207  array(
208  self::TABLE_Content => array(self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond),
209  )
210  );
211  $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
212 
213  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
214  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
215  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
216  }
217 
226  public function createPage()
227  {
228  parent::createPage();
229  $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
230  $this->assertAssertionDataSet('createPage');
231 
232  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
233  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
234  ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
235  }
236 
241  public function modifyPage()
242  {
243  parent::modifyPage();
244  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
245  $this->assertAssertionDataSet('modifyPage');
246 
247  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
248  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
249  ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
250  }
251 
256  public function deletePage()
257  {
258  parent::deletePage();
259  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
260  $this->assertAssertionDataSet('deletePage');
261 
262  $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
263  $this->assertContains('PageNotFoundException', $response->getError());
264  }
265 
270  public function copyPage()
271  {
272  parent::copyPage();
273  $this->actionService->publishRecords(
274  array(
275  self::TABLE_Page => array($this->recordIds['newPageId']),
276  self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
277  )
278  );
279  $this->assertAssertionDataSet('copyPage');
280 
281  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
282  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
283  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
284  }
285 
290  public function localizePage()
291  {
292  parent::localizePage();
293  $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
294  $this->assertAssertionDataSet('localizePage');
295 
296  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
297  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
298  ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
299  }
300 
305  public function changePageSorting()
306  {
307  parent::changePageSorting();
308  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
309  $this->assertAssertionDataSet('changePageSorting');
310 
311  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
312  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
313  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
314  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
315  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
316  }
317 
322  public function movePageToDifferentPage()
323  {
324  parent::movePageToDifferentPage();
325  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
326  $this->assertAssertionDataSet('movePageToDifferentPage');
327 
328  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
329  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
330  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
331  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
332  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
333  }
334 
340  {
341  parent::movePageToDifferentPageAndChangeSorting();
342  $this->actionService->publishRecords(
343  array(
344  self::TABLE_Page => array(self::VALUE_PageId, self::VALUE_PageIdTarget),
345  )
346  );
347  $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
348 
349  $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
350  $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
351  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
352  $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
353  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
354  $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
355  $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
356  ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
357  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
358  }
359 
367  {
368  parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
369  $this->actionService->publishRecords(
370  array(
371  self::TABLE_Page => array(self::VALUE_PageIdTarget, $this->recordIds['newPageId']),
372  )
373  );
374  $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
375 
376  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
377  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
378  ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
379  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
380  }
381 }