TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
workspaces/Tests/Functional/DataHandling/ManyToMany/AbstractActionTestCase.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\ManyToMany;
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;
30  const VALUE_WorkspaceId = 1;
31 
32  const TABLE_Page = 'pages';
33  const TABLE_Content = 'tt_content';
34  const TABLE_Category = 'sys_category';
35  const TABLE_ContentCategory_ManyToMany = 'sys_category_record_mm';
36 
40  protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/ManyToMany/DataSet/';
41 
45  protected $coreExtensionsToLoad = [
46  'fluid',
47  'version',
48  'workspaces',
49  ];
50 
51  protected function setUp()
52  {
53  parent::setUp();
54  $this->importScenarioDataSet('LiveDefaultPages');
55  $this->importScenarioDataSet('LiveDefaultElements');
56  $this->importScenarioDataSet('ReferenceIndex');
57 
58  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts']);
59  $this->backendUser->workspace = self::VALUE_WorkspaceId;
60  }
61 
70  public function addCategoryRelation()
71  {
72  $this->actionService->modifyReferences(
73  self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', [self::VALUE_CategoryIdFirst, self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdLast]
74  );
75  }
76 
81  public function deleteCategoryRelation()
82  {
83  $this->actionService->modifyReferences(
84  self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', [self::VALUE_CategoryIdFirst]
85  );
86  }
87 
93  {
94  $this->actionService->modifyReferences(
95  self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdFirst]
96  );
97  }
98 
103  public function createContentAndAddRelation()
104  {
105  $newTableIds = $this->actionService->createNewRecord(
106  self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', 'categories' => self::VALUE_CategoryIdSecond]
107  );
108  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
109  }
110 
116  {
117  $newTableIds = $this->actionService->createNewRecord(
118  self::TABLE_Category, 0, ['title' => 'Testing #1', 'items' => 'tt_content_' . self::VALUE_ContentIdFirst]
119  );
120  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
121  }
122 
128  {
129  $newTableIds = $this->actionService->createNewRecords(
130  self::VALUE_PageId,
131  [
132  self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1'],
133  self::TABLE_Content => ['header' => 'Testing #1', 'categories' => '__previousUid'],
134  ]
135  );
136  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
137  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
138  }
139 
145  {
146  $newTableIds = $this->actionService->createNewRecords(
147  self::VALUE_PageId,
148  [
149  self::TABLE_Content => ['header' => 'Testing #1'],
150  self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1', 'items' => 'tt_content___previousUid'],
151  ]
152  );
153  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
154  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
155  }
156 
158  {
159  $newTableIds = $this->actionService->createNewRecords(
160  self::VALUE_PageId,
161  [
162  self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1'],
163  self::TABLE_Content => ['header' => 'Testing #1'],
164  ]
165  );
166  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
167  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
168 
169  $this->actionService->modifyRecord(
170  self::TABLE_Content, $this->recordIds['newContentId'], ['categories' => $this->recordIds['newCategoryId']]
171  );
172  }
173 
175  {
176  $newTableIds = $this->actionService->createNewRecords(
177  self::VALUE_PageId,
178  [
179  self::TABLE_Content => ['header' => 'Testing #1'],
180  self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1', 'items' => 'tt_content___previousUid'],
181  ]
182  );
183  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
184  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
185 
186  $this->actionService->modifyRecord(
187  self::TABLE_Category, $this->recordIds['newCategoryId'], ['items' => 'tt_content_' . $this->recordIds['newContentId']]
188  );
189  }
190 
194  public function modifyCategoryOfRelation()
195  {
196  $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
197  }
198 
202  public function modifyContentOfRelation()
203  {
204  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
205  }
206 
210  public function modifyBothsOfRelation()
211  {
212  $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
213  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
214  }
215 
219  public function deleteContentOfRelation()
220  {
221  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
222  }
223 
227  public function deleteCategoryOfRelation()
228  {
229  $this->actionService->deleteRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
230  }
231 
235  public function copyContentOfRelation()
236  {
237  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
238  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
239  }
240 
244  public function copyCategoryOfRelation()
245  {
246  $newTableIds = $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, 0);
247  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
248  }
249 
253  public function localizeContentOfRelation()
254  {
255  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
256  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
257  }
258 
262  public function localizeCategoryOfRelation()
263  {
264  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
265  $this->recordIds['localizedCategoryId'] = $localizedTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
266  }
267 
272  {
273  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
274  }
275 
279  public function copyPage()
280  {
281  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
282  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
283  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
284  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
285  }
286 }
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])