[TASK] Streamline DataHandler functional tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / InlineRelationalRecordEditing / ForeignField / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\InlineRelationalRecordEditing\ForeignField;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Oliver Hader <oliver.hader@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 require_once __DIR__ . '/../../../../../../core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php';
28
29 /**
30 * Functional test for the DataHandler
31 */
32 abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase {
33
34 const VALUE_PageId = 89;
35 const VALUE_PageIdTarget = 90;
36 const VALUE_PageIdWebsite = 1;
37 const VALUE_ContentIdFirst = 297;
38 const VALUE_ContentIdLast = 298;
39 const VALUE_LanguageId = 1;
40
41 const TABLE_Page = 'pages';
42 const TABLE_Content = 'tt_content';
43 const TABLE_Hotel = 'tx_irretutorial_1nff_hotel';
44 const TABLE_Offer = 'tx_irretutorial_1nff_offer';
45
46 /**
47 * @var string
48 */
49 protected $dataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/';
50
51 /**
52 * @var array
53 */
54 protected $coreExtensionsToLoad = array(
55 'version',
56 'workspaces',
57 );
58
59 public function setUp() {
60 parent::setUp();
61 $this->importScenarioDataSet('LiveDefaultPages');
62 $this->importScenarioDataSet('LiveDefaultElements');
63 }
64
65 /**
66 * Parent content records
67 */
68
69 /**
70 * @test
71 */
72 public function createParentContentRecord() {
73 $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
74 $this->assertAssertionDataSet('createParentContentRecord');
75 }
76
77 /**
78 * @test
79 */
80 public function modifyParentContentRecord() {
81 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
82 $this->assertAssertionDataSet('modifyParentContentRecord');
83 }
84
85 /**
86 * @test
87 */
88 public function deleteParentContentRecord() {
89 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
90 $this->assertAssertionDataSet('deleteParentContentRecord');
91 }
92
93 /**
94 * @test
95 */
96 public function copyParentContentRecord() {
97 $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
98 $this->assertAssertionDataSet('copyParentContentRecord');
99 }
100
101 /**
102 * @test
103 */
104 public function localizeParentContentRecord() {
105 $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
106 $this->assertAssertionDataSet('localizeParentContentRecord');
107 }
108
109 /**
110 * @test
111 */
112 public function changeParentContentRecordSorting() {
113 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
114 $this->assertAssertionDataSet('changeParentContentRecordSorting');
115 }
116
117 /**
118 * @test
119 */
120 public function moveParentContentRecordToDifferentPage() {
121 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
122 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPage');
123 }
124
125 /**
126 * @test
127 */
128 public function moveParentContentRecordToDifferentPageAndChangeSorting() {
129 $this->markTestSkipped('Something seems to be wrong here...');
130 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
131 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
132 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPageAndChangeSorting');
133 }
134
135 /**
136 * Page records
137 */
138
139 /**
140 * @test
141 */
142 public function modifyPageRecord() {
143 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
144 $this->assertAssertionDataSet('modifyPageRecord');
145 }
146
147 /**
148 * @test
149 */
150 public function deletePageRecord() {
151 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
152 $this->assertAssertionDataSet('deletePageRecord');
153 }
154
155 /**
156 * @test
157 */
158 public function copyPageRecord() {
159 $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
160 $this->assertAssertionDataSet('copyPageRecord');
161 }
162
163 /**
164 * IRRE Child Records
165 */
166
167 /**
168 * @test
169 */
170 public function createParentContentRecordWithHotelAndOfferChildRecords() {
171 $this->actionService->createNewRecords(
172 self::VALUE_PageId,
173 array(
174 self::TABLE_Offer => array('title' => 'Offer #1'),
175 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
176 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
177 )
178 );
179 $this->assertAssertionDataSet('createParentContentRecordWithHotelAndOfferChildRecords');
180 }
181
182 /**
183 * @test
184 */
185 public function createAndCopyParentContentRecordWithHotelAndOfferChildRecords() {
186 // @todo Copying the new child records is broken in the Core
187 $newTableIds = $this->actionService->createNewRecords(
188 self::VALUE_PageId,
189 array(
190 self::TABLE_Offer => array('title' => 'Offer #1'),
191 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
192 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
193 )
194 );
195 $newContentId = $newTableIds['tt_content'][0];
196 $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
197 $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecords');
198 }
199
200 /**
201 * @test
202 */
203 public function modifyOnlyHotelChildRecord() {
204 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
205 $this->assertAssertionDataSet('modifyOnlyHotelChildRecord');
206 }
207
208 /**
209 * @test
210 */
211 public function modifyParentRecordAndChangeHotelChildRecordsSorting() {
212 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('tx_irretutorial_hotels' => '4,3'));
213 $this->assertAssertionDataSet('modifyParentRecordAndChangeHotelChildRecordsSorting');
214 }
215
216 /**
217 * @test
218 */
219 public function modifyParentRecordWithHotelChildRecord() {
220 $this->actionService->modifyRecords(
221 self::VALUE_PageId,
222 array(
223 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
224 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
225 )
226 );
227 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecord');
228 }
229
230 /**
231 * @test
232 */
233 public function modifyParentRecordAndAddHotelChildRecord() {
234 $this->actionService->modifyRecords(
235 self::VALUE_PageId,
236 array(
237 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
238 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'tx_irretutorial_hotels' => '5,__previousUid'),
239 )
240 );
241 $this->assertAssertionDataSet('modifyParentRecordAndAddHotelChildRecord');
242 }
243
244 /**
245 * @test
246 */
247 public function modifyParentRecordAndDeleteHotelChildRecord() {
248 $this->actionService->modifyRecord(
249 self::TABLE_Content,
250 self::VALUE_ContentIdFirst,
251 array('tx_irretutorial_hotels' => '3'),
252 array(self::TABLE_Hotel => array(4))
253 );
254 $this->assertAssertionDataSet('modifyParentRecordAndDeleteHotelChildRecord');
255 }
256
257 }