[TASK] Extend DataHandler IRRE functional tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / InlineRelationalRecordEditing / ForeignField / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\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 dirname(dirname(dirname(__FILE__))) . '/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/core/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/';
50
51 public function setUp() {
52 parent::setUp();
53 $this->importScenarioDataSet('LiveDefaultPages');
54 $this->importScenarioDataSet('LiveDefaultElements');
55 }
56
57 /**
58 * Parent content records
59 */
60
61 /**
62 * @test
63 */
64 public function createParentContentRecord() {
65 $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
66 $this->assertAssertionDataSet('createParentContentRecord');
67 }
68
69 /**
70 * @test
71 */
72 public function modifyParentContentRecord() {
73 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
74 $this->assertAssertionDataSet('modifyParentContentRecord');
75 }
76
77 /**
78 * @test
79 */
80 public function deleteParentContentRecord() {
81 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
82 $this->assertAssertionDataSet('deleteParentContentRecord');
83 }
84
85 /**
86 * @test
87 */
88 public function copyParentContentRecord() {
89 $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
90 $this->assertAssertionDataSet('copyParentContentRecord');
91 }
92
93 /**
94 * @test
95 */
96 public function localizeParentContentRecord() {
97 $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
98 $this->assertAssertionDataSet('localizeParentContentRecord');
99 }
100
101 /**
102 * @test
103 */
104 public function changeParentContentRecordSorting() {
105 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
106 $this->assertAssertionDataSet('changeParentContentRecordSorting');
107 }
108
109 /**
110 * @test
111 */
112 public function moveParentContentRecordToDifferentPage() {
113 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
114 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPage');
115 }
116
117 /**
118 * @test
119 */
120 public function moveParentContentRecordToDifferentPageAndChangeSorting() {
121 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
122 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
123 $this->assertAssertionDataSet('moveParentContentRecordToDifferentPageAndChangeSorting');
124 }
125
126 /**
127 * Page records
128 */
129
130 /**
131 * @test
132 */
133 public function modifyPageRecord() {
134 $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
135 $this->assertAssertionDataSet('modifyPageRecord');
136 }
137
138 /**
139 * @test
140 */
141 public function deletePageRecord() {
142 $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
143 $this->assertAssertionDataSet('deletePageRecord');
144 }
145
146 /**
147 * @test
148 */
149 public function copyPageRecord() {
150 $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
151 $this->assertAssertionDataSet('copyPageRecord');
152 }
153
154 /**
155 * IRRE Child Records
156 */
157
158 /**
159 * @test
160 */
161 public function createParentContentRecordWithHotelAndOfferChildRecords() {
162 $this->actionService->createNewRecords(
163 self::VALUE_PageId,
164 array(
165 self::TABLE_Offer => array('title' => 'Offer #1'),
166 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
167 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
168 )
169 );
170 $this->assertAssertionDataSet('createParentContentRecordWithHotelAndOfferChildRecords');
171 }
172
173 /**
174 * @test
175 */
176 public function createAndCopyParentContentRecordWithHotelAndOfferChildRecords() {
177 $newTableIds = $this->actionService->createNewRecords(
178 self::VALUE_PageId,
179 array(
180 self::TABLE_Offer => array('title' => 'Offer #1'),
181 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
182 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
183 )
184 );
185 $newContentId = $newTableIds[self::TABLE_Content][0];
186 $newHotelId = $newTableIds[self::TABLE_Hotel][0];
187 $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
188 $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecords');
189 }
190
191 /**
192 * @test
193 */
194 public function createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords() {
195 // @todo Localizing the new child records is broken in the Core
196 $newTableIds = $this->actionService->createNewRecords(
197 self::VALUE_PageId,
198 array(
199 self::TABLE_Offer => array('title' => 'Offer #1'),
200 self::TABLE_Hotel => array('title' => 'Hotel #1', 'offers' => '__previousUid'),
201 self::TABLE_Content => array('header' => 'Testing #1', 'tx_irretutorial_hotels' => '__previousUid'),
202 )
203 );
204 $newContentId = $newTableIds[self::TABLE_Content][0];
205 $newHotelId = $newTableIds[self::TABLE_Hotel][0];
206 $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
207 $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords');
208 }
209
210 /**
211 * @test
212 */
213 public function modifyOnlyHotelChildRecord() {
214 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
215 $this->assertAssertionDataSet('modifyOnlyHotelChildRecord');
216 }
217
218 /**
219 * @test
220 */
221 public function modifyParentRecordAndChangeHotelChildRecordsSorting() {
222 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('tx_irretutorial_hotels' => '4,3'));
223 $this->assertAssertionDataSet('modifyParentRecordAndChangeHotelChildRecordsSorting');
224 }
225
226 /**
227 * @test
228 */
229 public function modifyParentRecordWithHotelChildRecord() {
230 $this->actionService->modifyRecords(
231 self::VALUE_PageId,
232 array(
233 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
234 self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
235 )
236 );
237 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecord');
238 }
239
240 /**
241 * @test
242 */
243 public function modifyParentRecordAndAddHotelChildRecord() {
244 $this->actionService->modifyRecords(
245 self::VALUE_PageId,
246 array(
247 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
248 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'tx_irretutorial_hotels' => '5,__previousUid'),
249 )
250 );
251 $this->assertAssertionDataSet('modifyParentRecordAndAddHotelChildRecord');
252 }
253
254 /**
255 * @test
256 */
257 public function modifyParentRecordAndDeleteHotelChildRecord() {
258 $this->actionService->modifyRecord(
259 self::TABLE_Content,
260 self::VALUE_ContentIdFirst,
261 array('tx_irretutorial_hotels' => '3'),
262 array(self::TABLE_Hotel => array(4))
263 );
264 $this->assertAssertionDataSet('modifyParentRecordAndDeleteHotelChildRecord');
265 }
266
267 }