8ae14fb20b6562c1c31eb895b380d29eea063f8f
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Tests / Functional / DataHandling / FAL / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\Modify;
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__)) . '/AbstractActionTestCase.php';
28
29 /**
30 * Functional test for the DataHandler
31 */
32 class ActionTest extends \TYPO3\CMS\Workspaces\Tests\Functional\DataHandling\FAL\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/workspaces/Tests/Functional/DataHandling/FAL/Modify/DataSet/';
38
39 /**
40 * Content records
41 */
42
43 /**
44 * @test
45 * @see DataSet/Assertion/modifyContentRecord.csv
46 */
47 public function modifyContent() {
48 parent::modifyContent();
49 $this->assertAssertionDataSet('modifyContent');
50
51 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
52 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
53 $this->assertResponseContentStructureHasRecords(
54 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
55 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD'), TRUE
56 );
57 }
58
59 /**
60 * @test
61 * @see DataSet/Assertion/deleteContentRecord.csv
62 */
63 public function deleteContent() {
64 parent::deleteContent();
65 $this->assertAssertionDataSet('deleteContent');
66
67 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
68 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #1');
69 $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
70 }
71
72 /**
73 * @test
74 * @see DataSet/Assertion/copyContentRecord.csv
75 */
76 public function copyContent() {
77 parent::copyContent();
78 $this->assertAssertionDataSet('copyContent');
79
80 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
81 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2 (copy 1)');
82 $this->assertResponseContentStructureHasRecords(
83 $responseContent, self::TABLE_Content . ':' . $this->recordIds['copiedContentId'], self::FIELD_ContentImage,
84 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD'), TRUE
85 );
86 }
87
88 /**
89 * @test
90 * @see DataSet/Assertion/localizeContentRecord.csv
91 */
92 public function localizeContent() {
93 parent::localizeContent();
94 $this->assertAssertionDataSet('localizeContent');
95
96 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
97 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', '[Translate to Dansk:] Regular Element #2'));
98
99 // @todo Values in sys_file_reference are not copied during localization...
100 /*
101 $this->assertResponseContentStructureHasRecords(
102 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
103 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD'), TRUE
104 );
105 */
106 }
107
108 /**
109 * @test
110 * @see DataSet/Assertion/changeContentRecordSorting.csv
111 */
112 public function changeContentSorting() {
113 parent::changeContentSorting();
114 $this->assertAssertionDataSet('changeContentSorting');
115
116 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
117 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
118 $this->assertResponseContentStructureHasRecords(
119 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentImage,
120 self::TABLE_FileReference, 'title', array('Kasper', 'T3BOARD')
121 );
122 $this->assertResponseContentStructureHasRecords(
123 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
124 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD'), TRUE
125 );
126 }
127
128 /**
129 * @test
130 * @see DataSet/Assertion/moveContentRecordToDifferentPage.csv
131 */
132 public function moveContentToDifferentPage() {
133 parent::moveContentToDifferentPage();
134 $this->assertAssertionDataSet('moveContentToDifferentPage');
135
136 $responseContentSource = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
137 $this->assertResponseContentHasRecords($responseContentSource, self::TABLE_Content, 'header', 'Regular Element #1');
138 $this->assertResponseContentStructureHasRecords(
139 $responseContentSource, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentImage,
140 self::TABLE_FileReference, 'title', array('Kasper', 'T3BOARD'), TRUE
141 );
142
143 $responseContentTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
144 $this->assertResponseContentHasRecords($responseContentTarget, self::TABLE_Content, 'header', 'Regular Element #2');
145 $this->assertResponseContentStructureHasRecords(
146 $responseContentTarget, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
147 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD'), TRUE
148 );
149 }
150
151 /**
152 * @test
153 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
154 */
155 public function moveContentToDifferentPageAndChangeSorting() {
156 parent::moveContentToDifferentPageAndChangeSorting();
157 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
158
159 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
160 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
161 $this->assertResponseContentStructureHasRecords(
162 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentImage,
163 self::TABLE_FileReference, 'title', array('Kasper', 'T3BOARD'), TRUE
164 );
165 $this->assertResponseContentStructureHasRecords(
166 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
167 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD'), TRUE
168 );
169 }
170
171 /**
172 * File references
173 */
174
175 /**
176 * @test
177 * @see DataSets/createContentWFileReference.csv
178 */
179 public function createContentWithFileReference() {
180 parent::createContentWithFileReference();
181 $this->assertAssertionDataSet('createContentWFileReference');
182
183 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
184 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
185 $this->assertResponseContentStructureHasRecords(
186 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentImage,
187 self::TABLE_FileReference, 'title', 'Image #1', TRUE
188 );
189 }
190
191 /**
192 * @test
193 * @see DataSets/modifyContentWFileReference.csv
194 */
195 public function modifyContentWithFileReference() {
196 parent::modifyContentWithFileReference();
197 $this->assertAssertionDataSet('modifyContentWFileReference');
198
199 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
200 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
201 $this->assertResponseContentStructureHasRecords(
202 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
203 self::TABLE_FileReference, 'title', array('Taken at T3BOARD', 'Image #1'), TRUE
204 );
205 }
206
207 /**
208 * @test
209 * @see DataSets/modifyContentNAddFileReference.csv
210 */
211 public function modifyContentAndAddFileReference() {
212 parent::modifyContentAndAddFileReference();
213 $this->assertAssertionDataSet('modifyContentNAddFileReference');
214
215 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
216 $this->assertResponseContentStructureHasRecords(
217 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
218 self::TABLE_FileReference, 'title', array('Taken at T3BOARD', 'This is Kasper', 'Image #3'), TRUE
219 );
220 }
221
222 /**
223 * @test
224 * @see DataSets/modifyContentNDeleteFileReference.csv
225 */
226 public function modifyContentAndDeleteFileReference() {
227 parent::modifyContentAndDeleteFileReference();
228 $this->assertAssertionDataSet('modifyContentNDeleteFileReference');
229
230 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
231 $this->assertResponseContentStructureHasRecords(
232 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
233 self::TABLE_FileReference, 'title', 'This is Kasper', TRUE
234 );
235 $this->assertResponseContentStructureDoesNotHaveRecords(
236 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
237 self::TABLE_FileReference, 'title', 'Taken at T3BOARD'
238 );
239 }
240
241 /**
242 * @test
243 * @see DataSets/modifyContentNDeleteAllFileReference.csv
244 */
245 public function modifyContentAndDeleteAllFileReference() {
246 parent::modifyContentAndDeleteAllFileReference();
247 $this->assertAssertionDataSet('modifyContentNDeleteAllFileReference');
248
249 $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent();
250 $this->assertResponseContentStructureDoesNotHaveRecords(
251 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
252 self::TABLE_FileReference, 'title', array('Taken at T3BOARD', 'This is Kasper')
253 );
254 }
255
256 }