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/Regular/Publish/DataSet/';
28 
37  public function createContents() {
38  parent::createContents();
39  $this->actionService->publishRecords(
40  array(
41  self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
42  )
43  );
44  $this->assertAssertionDataSet('createContents');
45 
46  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
47  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
48  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1', 'Testing #2'));
49  }
50 
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  parent::createAndCopyContentAndDiscardCopiedContent();
72  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['newContentId']);
73  // Actually this is not required, since there's nothing to publish... but it's a test case!
74  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId'], FALSE);
75  $this->assertAssertionDataSet('createNCopyContentNDiscardCopiedContent');
76 
77  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
78  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
79  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
80  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
81  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1 (copy 1)'));
82  }
83 
88  public function modifyContent() {
89  parent::modifyContent();
90  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
91  $this->assertAssertionDataSet('modifyContent');
92 
93  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
94  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
95  ->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
96  }
97 
102  public function deleteContent() {
103  parent::deleteContent();
104  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
105  $this->assertAssertionDataSet('deleteContent');
106 
107  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
108  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
109  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
110  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
111  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
112  }
113 
119  parent::deleteLocalizedContentAndDeleteContent();
120  $this->actionService->publishRecords(
121  array(
122  self::TABLE_Content => array(self::VALUE_ContentIdThird, self::VALUE_ContentIdThirdLocalized),
123  )
124  );
125  $this->assertAssertionDataSet('deleteLocalizedContentNDeleteContent');
126 
127  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
128  $this->assertThat($responseSections, $this->getRequestSectionDoesNotHaveRecordConstraint()
129  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #3', '[Translate to Dansk:] Regular Element #3'));
130  }
131 
136  public function copyContent() {
137  parent::copyContent();
138  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['copiedContentId']);
139  $this->assertAssertionDataSet('copyContent');
140 
141  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
142  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
143  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2 (copy 1)'));
144  }
145 
150  public function localizeContent() {
151  parent::localizeContent();
152  $this->actionService->publishRecord(self::TABLE_Content, $this->recordIds['localizedContentId']);
153  $this->assertAssertionDataSet('localizeContent');
154 
155  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
156  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
157  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
158  }
159 
164  public function changeContentSorting() {
165  parent::changeContentSorting();
166  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
167  $this->assertAssertionDataSet('changeContentSorting');
168 
169  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
170  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
171  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
172  }
173 
178  public function moveContentToDifferentPage() {
179  parent::moveContentToDifferentPage();
180  $this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
181  $this->assertAssertionDataSet('moveContentToDifferentPage');
182 
183  $responseSectionsSource = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
184  $this->assertThat($responseSectionsSource, $this->getRequestSectionHasRecordConstraint()
185  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1'));
186  $responseSectionsTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
187  $this->assertThat($responseSectionsTarget, $this->getRequestSectionHasRecordConstraint()
188  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
189  }
190 
196  parent::moveContentToDifferentPageAndChangeSorting();
197  $this->actionService->publishRecords(
198  array(
199  self::TABLE_Content => array(self::VALUE_ContentIdFirst, self::VALUE_ContentIdSecond),
200  )
201  );
202  $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
203 
204  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0)->getResponseSections();
205  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
206  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
207  }
208 
217  public function createPage() {
218  parent::createPage();
219  $this->actionService->publishRecord(self::TABLE_Page, $this->recordIds['newPageId']);
220  $this->assertAssertionDataSet('createPage');
221 
222  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
223  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
224  ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
225  }
226 
231  public function modifyPage() {
232  parent::modifyPage();
233  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
234  $this->assertAssertionDataSet('modifyPage');
235 
236  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
237  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
238  ->setTable(self::TABLE_Page)->setField('title')->setValues('Testing #1'));
239  }
240 
245  public function deletePage() {
246  parent::deletePage();
247  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
248  $this->assertAssertionDataSet('deletePage');
249 
250  $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, FALSE);
251  $this->assertContains('PageNotFoundException', $response->getError());
252  }
253 
258  public function copyPage() {
259  parent::copyPage();
260  $this->actionService->publishRecords(
261  array(
262  self::TABLE_Page => array($this->recordIds['newPageId']),
263  self::TABLE_Content => array($this->recordIds['newContentIdFirst'], $this->recordIds['newContentIdLast']),
264  )
265  );
266  $this->assertAssertionDataSet('copyPage');
267 
268  $responseSections = $this->getFrontendResponse($this->recordIds['newPageId'], 0)->getResponseSections();
269  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
270  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
271  }
272 
277  public function localizePage() {
278  parent::localizePage();
279  $this->actionService->publishRecord(self::TABLE_PageOverlay, $this->recordIds['localizedPageOverlayId']);
280  $this->assertAssertionDataSet('localizePage');
281 
282  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
283  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
284  ->setTable(self::TABLE_Page)->setField('title')->setValues('[Translate to Dansk:] Relations'));
285  }
286 
291  public function changePageSorting() {
292  parent::changePageSorting();
293  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
294  $this->assertAssertionDataSet('changePageSorting');
295 
296  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
297  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
298  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
299  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
300  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
301  }
302 
307  public function movePageToDifferentPage() {
308  parent::movePageToDifferentPage();
309  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_PageId);
310  $this->assertAssertionDataSet('movePageToDifferentPage');
311 
312  $responseSections = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
313  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
314  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
315  $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
316  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
317  }
318 
324  parent::movePageToDifferentPageAndChangeSorting();
325  $this->actionService->publishRecords(
326  array(
327  self::TABLE_Page => array(self::VALUE_PageId, self::VALUE_PageIdTarget),
328  )
329  );
330  $this->assertAssertionDataSet('movePageToDifferentPageNChangeSorting');
331 
332  $responseSectionsPage = $this->getFrontendResponse(self::VALUE_PageId, 0)->getResponseSections();
333  $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
334  ->setTable(self::TABLE_Page)->setField('title')->setValues('Relations'));
335  $this->assertThat($responseSectionsPage, $this->getRequestSectionHasRecordConstraint()
336  ->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #1', 'Regular Element #2'));
337  $responseSectionsWebsite = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
338  $this->assertThat($responseSectionsWebsite, $this->getRequestSectionStructureHasRecordConstraint()
339  ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
340  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Relations', 'DataHandlerTest'));
341  }
342 
350  parent::movePageToDifferentPageAndCreatePageAfterMovedPage();
351  $this->actionService->publishRecords(
352  array(
353  self::TABLE_Page => array(self::VALUE_PageIdTarget, $this->recordIds['newPageId']),
354  )
355  );
356  $this->assertAssertionDataSet('movePageToDifferentPageNCreatePageAfterMovedPage');
357 
358  $responseSections = $this->getFrontendResponse(self::VALUE_PageIdWebsite, 0)->getResponseSections();
359  $this->assertThat($responseSections, $this->getRequestSectionStructureHasRecordConstraint()
360  ->setRecordIdentifier(self::TABLE_Page . ':' . self::VALUE_PageIdWebsite)->setRecordField('__pages')
361  ->setTable(self::TABLE_Page)->setField('title')->setValues('Target', 'Testing #1', 'DataHandlerTest'));
362  }
363 
369  parent::createPlaceholdersAndDeleteDraftParentPage();
370  $this->actionService->publishRecord(self::TABLE_Page, self::VALUE_ParentPageId);
371  $this->assertAssertionDataSet('createPlaceholdersAndDeleteDraftParentPage');
372  }
373 
374 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=TRUE)