db227695cb1c015b6ab0b7b29560a57479bdcd5d
[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 * @test
51 * @see DataSet/createContentRecordAndAddCategoryRelation.csv
52 */
53 public function createContentAndAddRelation()
54 {
55 $newTableIds = $this->actionService->createNewRecord(
56 self::TABLE_Content,
57 self::VALUE_PageId,
58 ['header' => 'Testing #1', 'categories' => self::VALUE_CategoryIdSecond]
59 );
60 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
61 }
62
63 /**
64 * @test
65 * @see DataSet/createCategoryRecordAndAddCategoryRelation.csv
66 */
67 public function createCategoryAndAddRelation()
68 {
69 $newTableIds = $this->actionService->createNewRecord(
70 self::TABLE_Category,
71 0,
72 ['title' => 'Testing #1', 'items' => 'tt_content_' . self::VALUE_ContentIdFirst]
73 );
74 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
75 }
76
77 /**
78 * @test
79 * @see DataSet/createContentRecordAndCreateCategoryRelation.csv
80 */
81 public function createContentAndCreateRelation()
82 {
83 $newTableIds = $this->actionService->createNewRecords(
84 self::VALUE_PageId,
85 [
86 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1'],
87 self::TABLE_Content => ['header' => 'Testing #1', 'categories' => '__previousUid'],
88 ]
89 );
90 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
91 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
92 }
93
94 /**
95 * @test
96 * @see DataSet/createCategoryRecordAndCreateCategoryRelation.csv
97 */
98 public function createCategoryAndCreateRelation()
99 {
100 $newTableIds = $this->actionService->createNewRecords(
101 self::VALUE_PageId,
102 [
103 self::TABLE_Content => ['header' => 'Testing #1'],
104 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1', 'items' => 'tt_content___previousUid'],
105 ]
106 );
107 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
108 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
109 }
110
111 public function createContentWithCategoryAndAddRelation()
112 {
113 $newTableIds = $this->actionService->createNewRecords(
114 self::VALUE_PageId,
115 [
116 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1'],
117 self::TABLE_Content => ['header' => 'Testing #1'],
118 ]
119 );
120 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
121 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
122
123 $this->actionService->modifyRecord(
124 self::TABLE_Content,
125 $this->recordIds['newContentId'],
126 ['categories' => $this->recordIds['newCategoryId']]
127 );
128 }
129
130 public function createCategoryWithContentAndAddRelation()
131 {
132 $newTableIds = $this->actionService->createNewRecords(
133 self::VALUE_PageId,
134 [
135 self::TABLE_Content => ['header' => 'Testing #1'],
136 self::TABLE_Category => ['pid' => 0, 'title' => 'Testing #1', 'items' => 'tt_content___previousUid'],
137 ]
138 );
139 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
140 $this->recordIds['newCategoryId'] = $newTableIds[self::TABLE_Category][0];
141
142 $this->actionService->modifyRecord(
143 self::TABLE_Category,
144 $this->recordIds['newCategoryId'],
145 ['items' => 'tt_content_' . $this->recordIds['newContentId']]
146 );
147 }
148 }