[TASK] Add functional test cases to DataHandler (live)
[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 modifyOnlyHotelChildRecord() {
177 $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
178 $this->assertAssertionDataSet('modifyOnlyHotelChildRecord');
179 }
180
181 /**
182 * @test
183 */
184 public function modifyParentRecordAndChangeHotelChildRecordsSorting() {
185 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('tx_irretutorial_hotels' => '4,3'));
186 $this->assertAssertionDataSet('modifyParentRecordAndChangeHotelChildRecordsSorting');
187 }
188
189 /**
190 * @test
191 */
192 public function modifyParentRecordWithHotelChildRecord() {
193 $this->actionService->modifyRecords(
194 self::VALUE_PageId,
195 array(
196 self::TABLE_Hotel => array('uid' => 4, 'title' => 'Testing #1'),
197 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'tx_irretutorial_hotels' => '3,4'),
198 )
199 );
200 $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecord');
201 }
202
203 /**
204 * @test
205 */
206 public function modifyParentRecordAndAddHotelChildRecord() {
207 $this->actionService->modifyRecords(
208 self::VALUE_PageId,
209 array(
210 self::TABLE_Hotel => array('uid' => '__NEW', 'title' => 'Hotel #2'),
211 self::TABLE_Content => array('uid' => self::VALUE_ContentIdLast, 'tx_irretutorial_hotels' => '5,__previousUid'),
212 )
213 );
214 $this->assertAssertionDataSet('modifyParentRecordAndAddHotelChildRecord');
215 }
216
217 /**
218 * @test
219 */
220 public function modifyParentRecordAndDeleteHotelChildRecord() {
221 $this->actionService->modifyRecord(
222 self::TABLE_Content,
223 self::VALUE_ContentIdFirst,
224 array('tx_irretutorial_hotels' => '3'),
225 array(self::TABLE_Hotel => array(4))
226 );
227 $this->assertAssertionDataSet('modifyParentRecordAndDeleteHotelChildRecord');
228 }
229
230 }