72f8b8161ac9821747a134754318a6a497e591be
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / ManyToMany / AbstractActionTestCase.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\ManyToMany;
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_CategoryIdFirst = 28;
40 const VALUE_CategoryIdSecond = 29;
41
42 const TABLE_Page = 'pages';
43 const TABLE_Content = 'tt_content';
44 const TABLE_Category = 'sys_category';
45 const TABLE_ContentCategory_ManyToMany = 'sys_category_record_mm';
46
47 /**
48 * @var string
49 */
50 protected $scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/ManyToMany/DataSet/';
51
52 public function setUp() {
53 parent::setUp();
54 $this->importScenarioDataSet('LiveDefaultPages');
55 $this->importScenarioDataSet('LiveDefaultElements');
56
57 $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
58 $this->backendUser->workspace = 0;
59 }
60
61 /**
62 * MM Relations
63 */
64
65 /**
66 * @test
67 * @see DataSet/Assertion/addCategoryRelation.csv
68 */
69 public function addCategoryRelation() {
70 $this->actionService->modifyReferences(
71 self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', array(self::VALUE_CategoryIdFirst, self::VALUE_CategoryIdSecond, 31)
72 );
73 }
74
75 /**
76 * @test
77 * @see DataSet/Assertion/deleteCategoryRelation.csv
78 */
79 public function deleteCategoryRelation() {
80 $this->actionService->modifyReferences(
81 self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', array(self::VALUE_CategoryIdFirst)
82 );
83 }
84
85 /**
86 * @test
87 * @see DataSet/Assertion/changeCategoryRelationSorting.csv
88 */
89 public function changeCategoryRelationSorting() {
90 $this->actionService->modifyReferences(
91 self::TABLE_Content, self::VALUE_ContentIdFirst, 'categories', array(self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdFirst)
92 );
93 }
94
95 /**
96 * @test
97 * @see DataSet/Assertion/modifyCategoryRecordOfCategoryRelation.csv
98 */
99 public function modifyCategoryOfRelation() {
100 $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, array('title' => 'Testing #1'));
101 }
102
103 /**
104 * @test
105 * @see DataSet/Assertion/modifyContentRecordOfCategoryRelation.csv
106 */
107 public function modifyContentOfRelation() {
108 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
109 }
110
111 /**
112 * @test
113 * @see DataSet/Assertion/modifyBothRecordsOfCategoryRelation.csv
114 */
115 public function modifyBothsOfRelation() {
116 $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, array('title' => 'Testing #1'));
117 $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('header' => 'Testing #1'));
118 }
119
120 /**
121 * @test
122 * @see DataSet/Assertion/deleteContentRecordOfCategoryRelation.csv
123 */
124 public function deleteContentOfRelation() {
125 $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
126 }
127
128 /**
129 * @test
130 * @see DataSet/Assertion/deleteCategoryRecordOfCategoryRelation.csv
131 */
132 public function deleteCategoryOfRelation() {
133 $this->actionService->deleteRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
134 }
135
136 /**
137 * @test
138 * @see DataSet/Assertion/copyContentRecordOfCategoryRelation.csv
139 */
140 public function copyContentOfRelation() {
141 $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
142 $this->recordIds['newContentId'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
143 }
144
145 /**
146 * @test
147 * @see DataSet/Assertion/copyCategoryRecordOfCategoryRelation.csv
148 */
149 public function copyCategoryOfRelation() {
150 $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, 0);
151 }
152
153 /**
154 * @test
155 * @see DataSet/Assertion/localizeContentRecordOfCategoryRelation.csv
156 */
157 public function localizeContentOfRelation() {
158 $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
159 }
160
161 /**
162 * @test
163 * @see DataSet/Assertion/localizeCategoryRecordOfCategoryRelation.csv
164 */
165 public function localizeCategoryOfRelation() {
166 $this->actionService->localizeRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
167 }
168
169 /**
170 * @test
171 * @see DataSet/Assertion/moveContentRecordOfCategoryRelationToDifferentPage.csv
172 */
173 public function moveContentOfRelationToDifferentPage() {
174 $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
175 }
176
177 /**
178 * @test
179 * @see DataSet/Assertion/copyPage.csv
180 */
181 public function copyPage() {
182 $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
183 $this->recordIds['newPageId'] = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
184 $this->recordIds['newContentIdFirst'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdFirst];
185 $this->recordIds['newContentIdLast'] = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
186 }
187
188 }