[TASK] Streamline functional data handling tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / ManyToMany / AbstractActionTestCase.php
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
17 /**
18 * Functional test for the DataHandler
19 */
20 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany\AbstractActionTestCase
21 {
22 const VALUE_CategoryIdLast = 31;
23 const VALUE_WorkspaceId = 1;
24
25 /**
26 * @var string
27 */
28 protected $scenarioDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/ManyToMany/DataSet/';
29
30 /**
31 * @var array
32 */
33 protected $coreExtensionsToLoad = [
34 'fluid',
35 'workspaces',
36 ];
37
38 protected function setUp()
39 {
40 parent::setUp();
41 $this->importScenarioDataSet('ReferenceIndex');
42 $this->backendUser->workspace = self::VALUE_WorkspaceId;
43 }
44
45 /**
46 * MM Relations
47 */
48
49 /**
50 * @see DataSet/createContentRecordAndAddCategoryRelation.csv
51 */
52 public function createContentAndAddRelation()
53 {
54 $newTableIds = $this->actionService->createNewRecord(
55 self::TABLE_Content,
56 self::VALUE_PageId,
57 ['header' => 'Testing #1', 'categories' => self::VALUE_CategoryIdSecond]
58 );
59 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
60 }
61
62 /**
63 * @see DataSet/createCategoryRecordAndAddCategoryRelation.csv
64 */
65 public function createCategoryAndAddRelation()
66 {
67 $newTableIds = $this->actionService->createNewRecord(
68 self::TABLE_Category,
69 0,
70 ['title' => 'Testing #1', 'items' => 'tt_content_' . self::VALUE_ContentIdFirst]
71 );
72 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
73 }
74
75 /**
76 * @see DataSet/createContentRecordAndCreateCategoryRelation.csv
77 */
78 public function createContentAndCreateRelation()
79 {
80 $newTableIds = $this->actionService->createNewRecords(
81 self::VALUE_PageId,
82 [
83 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1'],
84 self::TABLE_Content => ['header' => 'Testing #1', 'categories' => '__previousUid'],
85 ]
86 );
87 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
88 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
89 }
90
91 /**
92 * @see DataSet/createCategoryRecordAndCreateCategoryRelation.csv
93 */
94 public function createCategoryAndCreateRelation()
95 {
96 $newTableIds = $this->actionService->createNewRecords(
97 self::VALUE_PageId,
98 [
99 self::TABLE_Content => ['header' => 'Testing #1'],
100 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1', 'items' => 'tt_content___previousUid'],
101 ]
102 );
103 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
104 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
105 }
106
107 public function createContentWithCategoryAndAddRelation()
108 {
109 $newTableIds = $this->actionService->createNewRecords(
110 self::VALUE_PageId,
111 [
112 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1'],
113 self::TABLE_Content => ['header' => 'Testing #1'],
114 ]
115 );
116 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
117 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
118
119 $this->actionService->modifyRecord(
120 self::TABLE_Content,
121 $this->recordIds['newContentId'],
122 ['categories' => $this->recordIds['newCategoryId']]
123 );
124 }
125
126 public function createCategoryWithContentAndAddRelation()
127 {
128 $newTableIds = $this->actionService->createNewRecords(
129 self::VALUE_PageId,
130 [
131 self::TABLE_Content => ['header' => 'Testing #1'],
132 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1', 'items' => 'tt_content___previousUid'],
133 ]
134 );
135 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
136 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
137
138 $this->actionService->modifyRecord(
139 self::TABLE_Category,
140 $this->recordIds['newCategoryId'],
141 ['items' => 'tt_content_' . $this->recordIds['newContentId']]
142 );
143 }
144 }