TYPO3 CMS  TYPO3_8-7
AbstractActionTestCase.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 {
22  const VALUE_PageId = 89;
23  const VALUE_PageIdTarget = 90;
24  const VALUE_ContentIdFirst = 297;
25  const VALUE_ContentIdLast = 298;
26  const VALUE_LanguageId = 1;
31 
32  const TABLE_Content = 'tt_content';
33  const TABLE_Element = 'tx_testdatahandler_element';
34 
35  const FIELD_ContentElement = 'tx_testdatahandler_group';
36 
40  protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Group/DataSet/';
41 
42  protected function setUp()
43  {
44  $this->testExtensionsToLoad[] = 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler';
45 
46  parent::setUp();
47  $this->importScenarioDataSet('LiveDefaultPages');
48  $this->importScenarioDataSet('LiveDefaultElements');
49  $this->importScenarioDataSet('ReferenceIndex');
50 
51  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
52  }
53 
62  public function addElementRelation()
63  {
64  $this->actionService->modifyReferences(
65  self::TABLE_Content,
66  self::VALUE_ContentIdFirst,
67  self::FIELD_ContentElement,
68  [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
69  );
70  }
71 
76  public function deleteElementRelation()
77  {
78  $this->actionService->modifyReferences(
79  self::TABLE_Content,
80  self::VALUE_ContentIdFirst,
81  self::FIELD_ContentElement,
82  [self::VALUE_ElementIdFirst]
83  );
84  }
85 
90  public function changeElementSorting()
91  {
92  $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
93  }
94 
99  public function changeElementRelationSorting()
100  {
101  $this->actionService->modifyReferences(
102  self::TABLE_Content,
103  self::VALUE_ContentIdFirst,
104  self::FIELD_ContentElement,
105  [self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst]
106  );
107  }
108 
114  {
115  $newTableIds = $this->actionService->createNewRecord(
116  self::TABLE_Content,
117  self::VALUE_PageId,
118  ['header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst]
119  );
120  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
121  }
122 
128  {
129  $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, ['title' => 'Testing #1']);
130  $this->recordIds['newElementId'] = $newElementIds[self::TABLE_Element][0];
131  // It's not possible to use "NEW..." values for the TCA type 'group'
132  $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']]);
133  $this->recordIds['newContentId'] = $newContentIds[self::TABLE_Content][0];
134  }
135 
140  public function modifyElementOfRelation()
141  {
142  $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
143  }
144 
149  public function modifyContentOfRelation()
150  {
151  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
152  }
153 
158  public function modifyBothSidesOfRelation()
159  {
160  $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
161  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
162  }
163 
168  public function deleteContentOfRelation()
169  {
170  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
171  }
172 
177  public function deleteElementOfRelation()
178  {
179  $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
180  }
181 
186  public function copyContentOfRelation()
187  {
188  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
189  $this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
190  }
191 
196  public function copyElementOfRelation()
197  {
198  $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
199  $this->recordIds['copiedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
200  }
201 
207  {
208  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
209  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
210  }
211 
217  {
218  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
219  $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
220  }
221 
226  public function localizeContentOfRelation()
227  {
228  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
229  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
230  }
231 
233  {
234  $GLOBALS['TCA']['tt_content']['columns'][self::FIELD_ContentElement]['config']['behaviour']['allowLanguageSynchronization'] = true;
235  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
236  $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
237  $this->actionService->modifyReferences(
238  self::TABLE_Content,
239  self::VALUE_ContentIdLast,
240  self::FIELD_ContentElement,
241  [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond]
242  );
243  }
244 
246  {
247  $GLOBALS['TCA']['tt_content']['columns'][self::FIELD_ContentElement]['config']['behaviour']['allowLanguageSynchronization'] = true;
248  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
249  $this->recordIds['localizedContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
250  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['localizedContentIdFirst'], self::VALUE_LanguageIdSecond);
251  $this->recordIds['localizedContentIdSecond'] = $newTableIds[self::TABLE_Content][$this->recordIds['localizedContentIdFirst']];
252  $this->actionService->modifyRecord(
253  self::TABLE_Content,
254  $this->recordIds['localizedContentIdSecond'],
255  ['l10n_state' => [self::FIELD_ContentElement => 'source']]
256  );
257  $this->actionService->modifyReferences(
258  self::TABLE_Content,
259  self::VALUE_ContentIdLast,
260  self::FIELD_ContentElement,
261  [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond]
262  );
263  }
264 
269  public function localizeElementOfRelation()
270  {
271  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
272  $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
273  }
274 
280  {
281  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
282  }
283 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']