9c30af742625905cc051fff6e7baa406bce983cd
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / FAL / Modify / ActionTest.php
1 <?php
2 namespace TYPO3\CMS\Core\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\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase {
33
34 /**
35 * @var string
36 */
37 protected $assertionDataSetDirectory = 'typo3/sysext/core/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)->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')
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)->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)->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')
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)->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')
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)->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')
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)->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')
141 );
142 $responseContentTarget = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
143 $this->assertResponseContentHasRecords($responseContentTarget, self::TABLE_Content, 'header', 'Regular Element #2');
144 $this->assertResponseContentStructureHasRecords(
145 $responseContentTarget, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
146 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD')
147 );
148 }
149
150 /**
151 * @test
152 * @see DataSet/Assertion/moveContentRecordToDifferentPageAndChangeSorting.csv
153 */
154 public function moveContentToDifferentPageAndChangeSorting() {
155 parent::moveContentToDifferentPageAndChangeSorting();
156 $this->assertAssertionDataSet('moveContentToDifferentPageNChangeSorting');
157
158 $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
159 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #1', 'Regular Element #2'));
160 $this->assertResponseContentStructureHasRecords(
161 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, self::FIELD_ContentImage,
162 self::TABLE_FileReference, 'title', array('Kasper', 'T3BOARD')
163 );
164 $this->assertResponseContentStructureHasRecords(
165 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
166 self::TABLE_FileReference, 'title', array('This is Kasper', 'Taken at T3BOARD')
167 );
168 }
169
170 /**
171 * File references
172 */
173
174 /**
175 * @test
176 * @see DataSets/createContentWFileReference.csv
177 */
178 public function createContentWithFileReference() {
179 parent::createContentWithFileReference();
180 $this->assertAssertionDataSet('createContentWFileReference');
181
182 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
183 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
184 $this->assertResponseContentStructureHasRecords(
185 $responseContent, self::TABLE_Content . ':' . $this->recordIds['newContentId'], self::FIELD_ContentImage,
186 self::TABLE_FileReference, 'title', 'Image #1'
187 );
188 }
189
190 /**
191 * @test
192 * @see DataSets/modifyContentWFileReference.csv
193 */
194 public function modifyContentWithFileReference() {
195 parent::modifyContentWithFileReference();
196 $this->assertAssertionDataSet('modifyContentWFileReference');
197
198 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
199 $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
200 $this->assertResponseContentStructureHasRecords(
201 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
202 self::TABLE_FileReference, 'title', array('Taken at T3BOARD', 'Image #1')
203 );
204 }
205
206 /**
207 * @test
208 * @see DataSets/modifyContentNAddFileReference.csv
209 */
210 public function modifyContentAndAddFileReference() {
211 parent::modifyContentAndAddFileReference();
212 $this->assertAssertionDataSet('modifyContentNAddFileReference');
213
214 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
215 $this->assertResponseContentStructureHasRecords(
216 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
217 self::TABLE_FileReference, 'title', array('Taken at T3BOARD', 'This is Kasper', 'Image #3')
218 );
219 }
220
221 /**
222 * @test
223 * @see DataSets/modifyContentNDeleteFileReference.csv
224 */
225 public function modifyContentAndDeleteFileReference() {
226 parent::modifyContentAndDeleteFileReference();
227 $this->assertAssertionDataSet('modifyContentNDeleteFileReference');
228
229 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
230 $this->assertResponseContentStructureHasRecords(
231 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
232 self::TABLE_FileReference, 'title', 'This is Kasper'
233 );
234 $this->assertResponseContentStructureDoesNotHaveRecords(
235 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
236 self::TABLE_FileReference, 'title', 'Taken at T3BOARD'
237 );
238 }
239
240 /**
241 * @test
242 * @see DataSets/modifyContentNDeleteAllFileReference.csv
243 */
244 public function modifyContentAndDeleteAllFileReference() {
245 parent::modifyContentAndDeleteAllFileReference();
246 $this->assertAssertionDataSet('modifyContentNDeleteAllFileReference');
247
248 $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
249 $this->assertResponseContentStructureDoesNotHaveRecords(
250 $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, self::FIELD_ContentImage,
251 self::TABLE_FileReference, 'title', array('Taken at T3BOARD', 'This is Kasper')
252 );
253 }
254
255 }