1bf63844db5dbc14a8792ab667b3e8396142ce8a
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / Select / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Select;
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(__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_ContentIdFirst = 297;
37 const VALUE_ContentIdLast = 298;
38 const VALUE_LanguageId = 1;
39 const VALUE_ElementIdFirst = 1;
40 const VALUE_ElementIdSecond = 2;
41 const VALUE_ElementIdThird = 3;
42
43 const TABLE_Content = 'tt_content';
44 const TABLE_Element = 'tx_testdatahandler_element';
45
46 const FIELD_ContentElement = 'tx_testdatahandler_select';
47
48 /**
49 * @var string
50 */
51 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Select/DataSet/';
52
53 public function setUp() {
54 $this->testExtensionsToLoad[] = 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler';
55
56 parent::setUp();
57 $this->importScenarioDataSet('LiveDefaultPages');
58 $this->importScenarioDataSet('LiveDefaultElements');
59 $this->importScenarioDataSet('ReferenceIndex');
60
61 $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
62 }
63
64 /**
65 * Relations
66 */
67
68 /**
69 * @test
70 * @see DataSet/addElementRelation.csv
71 */
72 public function addElementRelation() {
73 $this->actionService->modifyReferences(
74 self::TABLE_Content, self::VALUE_ContentIdFirst, self::FIELD_ContentElement, array(self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird)
75 );
76 }
77
78 /**
79 * @test
80 * @see DataSet/deleteElementRelation.csv
81 */
82 public function deleteElementRelation() {
83 $this->actionService->modifyReferences(
84 self::TABLE_Content, self::VALUE_ContentIdFirst, self::FIELD_ContentElement, array(self::VALUE_ElementIdFirst)
85 );
86 }
87
88 /**
89 * @test
90 * @see DataSet/changeElementSorting.csv
91 */
92 public function changeElementSorting() {
93 $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
94 }
95
96 /**
97 * @test
98 * @see DataSet/changeElementRelationSorting.csv
99 */
100 public function changeElementRelationSorting() {
101 $this->actionService->modifyReferences(
102 self::TABLE_Content, self::VALUE_ContentIdFirst, self::FIELD_ContentElement, array(self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst)
103 );
104 }
105
106 /**
107 * @test
108 * @see DataSet/createContentNAddRelation.csv
109 */
110 public function createContentAndAddElementRelation() {
111 $newTableIds = $this->actionService->createNewRecord(
112 self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst)
113 );
114 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][0];
115 }
116
117 /**
118 * @test
119 * @see DataSet/createContentNCreateRelation.csv
120 */
121 public function createContentAndCreateElementRelation() {
122 $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, array('title' => 'Testing #1'));
123 $this->recordIds['newElementId'] = $newElementIds[self::TABLE_Element][0];
124 // It's not possible to use "NEW..." values for the TCA type 'select' in a workspace, in live it would have been fine
125 $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']));
126 $this->recordIds['newContentId'] = $newContentIds[self::TABLE_Content][0];
127 }
128
129 /**
130 * @test
131 * @see DataSet/modifyElementOfRelation.csv
132 */
133 public function modifyElementOfRelation() {
134 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, array('title' => 'Testing #1'));
135 }
136
137 /**
138 * @test
139 * @see DataSet/modifyContentOfRelation.csv
140 */
141 public function modifyContentOfRelation() {
142 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
143 }
144
145 /**
146 * @test
147 * @see DataSet/modifyBothSidesOfRelation.csv
148 */
149 public function modifyBothSidesOfRelation() {
150 $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, array('title' => 'Testing #1'));
151 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
152 }
153
154 /**
155 * @test
156 * @see DataSet/deleteContentOfRelation.csv
157 */
158 public function deleteContentOfRelation() {
159 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
160 }
161
162 /**
163 * @test
164 * @see DataSet/deleteElementOfRelation.csv
165 */
166 public function deleteElementOfRelation() {
167 $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
168 }
169
170 /**
171 * @test
172 * @see DataSet/copyContentOfRelation.csv
173 */
174 public function copyContentOfRelation() {
175 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
176 $this->recordIds['copiedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
177 }
178
179 /**
180 * @test
181 * @see DataSet/copyElementOfRelation.csv
182 */
183 public function copyElementOfRelation() {
184 $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
185 $this->recordIds['copiedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
186 }
187
188 /**
189 * @test
190 * @see DataSet/localizeContentOfRelation.csv
191 */
192 public function localizeContentOfRelation() {
193 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
194 $this->recordIds['localizedContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
195 }
196
197 /**
198 * @test
199 * @see DataSet/localizeElementOfRelation.csv
200 */
201 public function localizeElementOfRelation() {
202 $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
203 $this->recordIds['localizedElementId'] = $newTableIds[self::TABLE_Element][self::VALUE_ElementIdFirst];
204 }
205
206 /**
207 * @test
208 * @see DataSet/moveContentOfRelationToDifferentPage.csv
209 */
210 public function moveContentOfRelationToDifferentPage() {
211 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
212 }
213
214 }