TYPO3  7.6
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 
20 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
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 = array(
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, array('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', array(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', array(self::VALUE_CategoryIdFirst)
85  );
86  }
87 
93  {
94  $this->actionService->modifyReferences(
95  self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', array(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, array('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, array('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  array(
132  self::TABLE_Category => array('pid' => 0, 'title' => 'Testing #1'),
133  self::TABLE_Content => array('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  array(
149  self::TABLE_Content => array('header' => 'Testing #1'),
150  self::TABLE_Category => array('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 
160  public function modifyCategoryOfRelation()
161  {
162  $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, array('title' => 'Testing #1'));
163  }
164 
168  public function modifyContentOfRelation()
169  {
170  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
171  }
172 
176  public function modifyBothsOfRelation()
177  {
178  $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, array('title' => 'Testing #1'));
179  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
180  }
181 
185  public function deleteContentOfRelation()
186  {
187  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
188  }
189 
193  public function deleteCategoryOfRelation()
194  {
195  $this->actionService->deleteRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
196  }
197 
201  public function copyContentOfRelation()
202  {
203  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
204  $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
205  }
206 
210  public function copyCategoryOfRelation()
211  {
212  $newTableIds = $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, 0);
213  $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
214  }
215 
219  public function localizeContentOfRelation()
220  {
221  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
222  $this->recordIds['localizedContentId'] = $localizedTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
223  }
224 
228  public function localizeCategoryOfRelation()
229  {
230  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
231  $this->recordIds['localizedCategoryId'] = $localizedTableIds[self::TABLE_Category][self::VALUE_CategoryIdFirst];
232  }
233 
238  {
239  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
240  }
241 
245  public function copyPage()
246  {
247  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
248  $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
249  $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
250  $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
251  }
252 }