[TASK] Enable acceptance tests again
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / FormEngine / ElementsBasicInputCest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\FormEngine;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use Codeception\Example;
19 use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
20 use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree;
21
22 /**
23 * Tests for "elements_basic" simple input fields of ext:styleguide
24 */
25 class ElementsBasicInputCest extends AbstractElementsBasicCest
26 {
27 /**
28 * Open list module of styleguide elements basic page
29 *
30 * @param BackendTester $I
31 * @param PageTree $pageTree
32 */
33 public function _before(BackendTester $I, PageTree $pageTree)
34 {
35 $I->useExistingSession('admin');
36 $I->click('List');
37 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
38 $I->switchToContentFrame();
39
40 // Open record and wait until form is ready
41 $I->waitForText('elements basic', 20);
42 $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_basic a[data-original-title="Edit record"]';
43 $I->click($editRecordLinkCssPath);
44 $I->waitForElementNotVisible('#t3js-ui-block');
45 $I->waitForText('Edit Form', 3, 'h1');
46 }
47
48 /**
49 * Data provider to check various type=input variants
50 */
51 protected function simpleInputFieldsDataProvider()
52 {
53 return [
54 [
55 'label' => 'input_1',
56 'inputValue' => 'This is a demo text',
57 'expectedValue' => 'This is a demo text',
58 'expectedInternalValue' => 'This is a demo text',
59 'expectedValueAfterSave' => 'This is a demo text',
60 'comment' => '',
61 ],
62 [
63 'label' => 'input_2, size=10',
64 'inputValue' => 'This is a demo text with numbers and other characters 42 #!',
65 'expectedValue' => 'This is a demo text with numbers and other characters 42 #!',
66 'expectedInternalValue' => 'This is a demo text with numbers and other characters 42 #!',
67 'expectedValueAfterSave' => 'This is a demo text with numbers and other characters 42 #!',
68 'comment' => '',
69 ],
70 [
71 'label' => 'input_3 max=4',
72 'inputValue' => 'Kasper',
73 'expectedValue' => 'Kasp',
74 'expectedInternalValue' => 'Kasp',
75 'expectedValueAfterSave' => 'Kasp',
76 'comment' => '',
77 ],
78 [
79 'label' => 'input_4 eval=alpha',
80 'inputValue' => 'Kasper = TYPO3',
81 'expectedValue' => 'KasperTYPO',
82 'expectedInternalValue' => 'KasperTYPO',
83 'expectedValueAfterSave' => 'KasperTYPO',
84 'comment' => '',
85 ],
86 [
87 'label' => 'input_4 eval=alpha',
88 'inputValue' => 'Non-latin characters: ŠĐŽĆČ',
89 'expectedValue' => 'Nonlatincharacters',
90 'expectedInternalValue' => 'Nonlatincharacters',
91 'expectedValueAfterSave' => 'Nonlatincharacters',
92 'comment' => '',
93 ],
94 [
95 'label' => 'input_5 eval=alphanum',
96 'inputValue' => 'Kasper = TYPO3',
97 'expectedValue' => 'KasperTYPO3',
98 'expectedInternalValue' => 'KasperTYPO3',
99 'expectedValueAfterSave' => 'KasperTYPO3',
100 'comment' => '',
101 ],
102 [
103 'label' => 'input_10 eval=is_in, is_in=abc123',
104 'inputValue' => 'abcd1234',
105 'expectedValue' => 'abc123',
106 'expectedInternalValue' => 'abc123',
107 'expectedValueAfterSave' => 'abc123',
108 'comment' => '',
109 ],
110 [
111 'label' => 'input_10 eval=is_in, is_in=abc123',
112 'inputValue' => 'Kasper TYPO3',
113 'expectedValue' => 'a3',
114 'expectedInternalValue' => 'a3',
115 'expectedValueAfterSave' => 'a3',
116 'comment' => '',
117 ],
118 [
119 'label' => 'input_11 eval=lower',
120 'inputValue' => 'Kasper TYPO3!',
121 'expectedValue' => 'kasper typo3!',
122 'expectedInternalValue' => 'kasper typo3!',
123 'expectedValueAfterSave' => 'kasper typo3!',
124 'comment' => '',
125 ],
126 [
127 'label' => 'input_13 eval=nospace',
128 'inputValue' => ' Kasper TYPO3! ',
129 'expectedValue' => 'KasperTYPO3!',
130 'expectedInternalValue' => 'KasperTYPO3!',
131 'expectedValueAfterSave' => 'KasperTYPO3!',
132 'comment' => '',
133 ],
134 [
135 'label' => 'input_16 eval=password',
136 'inputValue' => 'Kasper',
137 'expectedValue' => '********',
138 'expectedInternalValue' => 'Kasper',
139 'expectedValueAfterSave' => 'Kasper',
140 'comment' => '',
141 ],
142 [
143 'label' => 'input_19 eval=trim',
144 'inputValue' => ' Kasper ',
145 'expectedValue' => 'Kasper',
146 'expectedInternalValue' => 'Kasper',
147 'expectedValueAfterSave' => 'Kasper',
148 'comment' => '',
149 ],
150 [
151 'label' => 'input_19 eval=trim',
152 'inputValue' => ' Kasper TYPO3 ',
153 'expectedValue' => 'Kasper TYPO3',
154 'expectedInternalValue' => 'Kasper TYPO3',
155 'expectedValueAfterSave' => 'Kasper TYPO3',
156 'comment' => '',
157 ],
158 [
159 'label' => 'input_23 eval=upper',
160 'inputValue' => 'Kasper TYPO3!',
161 'expectedValue' => 'KASPER TYPO3!',
162 'expectedInternalValue' => 'KASPER TYPO3!',
163 'expectedValueAfterSave' => 'KASPER TYPO3!',
164 'comment' => '',
165 ],
166 [
167 'label' => 'input_24 eval=year',
168 'inputValue' => '2016',
169 'expectedValue' => '2016',
170 'expectedInternalValue' => '2016',
171 'expectedValueAfterSave' => '2016',
172 'comment' => '',
173 ],
174 [
175 'label' => 'input_24 eval=year',
176 'inputValue' => '12',
177 'expectedValue' => '12',
178 'expectedInternalValue' => '12',
179 'expectedValueAfterSave' => '12',
180 'comment' => '',
181 ],
182 [
183 'label' => 'input_24 eval=year',
184 'inputValue' => 'Kasper',
185 'expectedValue' => date('Y'),
186 'expectedInternalValue' => date('Y'),
187 'expectedValueAfterSave' => date('Y'),
188 'comment' => 'Invalid character is converted to current year',
189 ]
190 ];
191 }
192
193 /**
194 * @dataProvider simpleInputFieldsDataProvider
195 * @param BackendTester $I
196 * @param Example $testData
197 */
198 public function simpleInputFields(BackendTester $I, Example $testData)
199 {
200 $this->runInputFieldTest($I, $testData);
201 }
202
203 /**
204 * Test various type=input fields having eval
205 */
206 protected function simpleEvalInputFieldsDataProvider()
207 {
208 return [
209 [
210 'label' => 'input_8 eval=double2',
211 'inputValue' => '12.335',
212 'expectedValue' => '12.34',
213 'expectedInternalValue' => '12.34',
214 'expectedValueAfterSave' => '12.34',
215 'comment' => '',
216 ],
217 [
218 'label' => 'input_8 eval=double2',
219 'inputValue' => '12,335', // comma as delimiter
220 'expectedValue' => '12.34',
221 'expectedInternalValue' => '12.34',
222 'expectedValueAfterSave' => '12.34',
223 'comment' => '',
224 ],
225 [
226 'label' => 'input_8 eval=double2',
227 'inputValue' => '1.1', // dot as delimiter
228 'expectedValue' => '1.10',
229 'expectedInternalValue' => '1.10',
230 'expectedValueAfterSave' => '1.10',
231 'comment' => '',
232 ],
233 [
234 'label' => 'input_8 eval=double2',
235 'inputValue' => 'TYPO3', // word having a number at end
236 'expectedValue' => '3.00',
237 'expectedInternalValue' => '3.00',
238 'expectedValueAfterSave' => '3.00',
239 'comment' => '',
240 ],
241 [
242 'label' => 'input_8 eval=double2',
243 'inputValue' => '3TYPO', // word having a number in front
244 'expectedValue' => '3.00',
245 'expectedInternalValue' => '3.00',
246 'expectedValueAfterSave' => '3.00',
247 'comment' => '',
248 ],
249 [
250 'label' => 'input_9 eval=int',
251 'inputValue' => '12.335',
252 'expectedValue' => '12',
253 'expectedInternalValue' => '12',
254 'expectedValueAfterSave' => '12',
255 'comment' => '',
256 ],
257 [
258 'label' => 'input_9 eval=int',
259 'inputValue' => '12,9',
260 'expectedValue' => '129',
261 'expectedInternalValue' => '129',
262 'expectedValueAfterSave' => '129',
263 'comment' => '',
264 ],
265 /**
266 [
267 // @todo this one probably broke with the html type="number" patch
268 'label' => 'input_9 eval=int',
269 'inputValue' => 'TYPO3',
270 'expectedValue' => '0',
271 'expectedInternalValue' => '0',
272 'expectedValueAfterSave' => '0',
273 'comment' => '',
274 ],
275 */
276 [
277 'label' => 'input_9 eval=int',
278 'inputValue' => '3TYPO',
279 'expectedValue' => '3',
280 'expectedInternalValue' => '3',
281 'expectedValueAfterSave' => '3',
282 'comment' => '',
283 ],
284 [
285 'label' => 'input_15 eval=num',
286 'inputValue' => '12.335',
287 'expectedValue' => '12335',
288 'expectedInternalValue' => '12335',
289 'expectedValueAfterSave' => '12335',
290 'comment' => '',
291 ],
292 [
293 'label' => 'input_15 eval=num',
294 'inputValue' => '12,9',
295 'expectedValue' => '129',
296 'expectedInternalValue' => '129',
297 'expectedValueAfterSave' => '129',
298 'comment' => '',
299 ],
300 [
301 'label' => 'input_15 eval=num',
302 'inputValue' => 'TYPO3',
303 'expectedValue' => '3',
304 'expectedInternalValue' => '3',
305 'expectedValueAfterSave' => '3',
306 'comment' => '',
307 ],
308 [
309 'label' => 'input_15 eval=num',
310 'inputValue' => '3TYPO',
311 'expectedValue' => '3',
312 'expectedInternalValue' => '3',
313 'expectedValueAfterSave' => '3',
314 'comment' => '',
315 ],
316 ];
317 }
318
319 /**
320 * @dataProvider simpleEvalInputFieldsDataProvider
321 * @param BackendTester $I
322 * @param Example $testData
323 */
324 public function simpleEvalInputFields(BackendTester $I, Example $testData)
325 {
326 $this->runInputFieldTest($I, $testData);
327 }
328
329 /**
330 * type=input range and md5 field tests
331 */
332 protected function simpleRangeAndMd5FieldsDataProvider()
333 {
334 return [
335 /**
336 [
337 // @todo this one probably broke with the type="number" patch
338 'label' => 'input_25 eval=int, default=0, range lower=-2, range upper=2',
339 'inputValue' => 'Kasper TYPO3',
340 'expectedValue' => '0',
341 'expectedInternalValue' => '0',
342 'expectedValueAfterSave' => '0',
343 'comment' => '',
344 ],
345 */
346 [
347 'label' => 'input_25 eval=int, default=0, range lower=-2, range upper=2',
348 'inputValue' => '2',
349 'expectedValue' => '2',
350 'expectedInternalValue' => '2',
351 'expectedValueAfterSave' => '2',
352 'comment' => '',
353 ],
354 [
355 'label' => 'input_25 eval=int, default=0, range lower=-2, range upper=2',
356 'inputValue' => '-1',
357 'expectedValue' => '-1',
358 'expectedInternalValue' => '-1',
359 'expectedValueAfterSave' => '-1',
360 'comment' => '',
361 ],
362 [
363 'label' => 'input_12 eval=md5',
364 'inputValue' => 'Kasper TYPO3!',
365 'expectedValue' => '748469dd64911af8df8f9a3dcb2c9378',
366 'expectedInternalValue' => '748469dd64911af8df8f9a3dcb2c9378',
367 'expectedValueAfterSave' => '748469dd64911af8df8f9a3dcb2c9378',
368 'comment' => '',
369 ],
370 [
371 'label' => 'input_12 eval=md5',
372 'inputValue' => ' Kasper TYPO3! ',
373 'expectedValue' => '792a085606250c47d6ebb8c98804d5b0',
374 'expectedInternalValue' => '792a085606250c47d6ebb8c98804d5b0',
375 'expectedValueAfterSave' => '792a085606250c47d6ebb8c98804d5b0',
376 'comment' => 'Check whitespaces are not trimmed.',
377 ],
378 ];
379 }
380
381 /**
382 * @dataProvider simpleRangeAndMd5FieldsDataProvider
383 * @param BackendTester $I
384 * @param Example $testData
385 */
386 public function simpleRangeAndMd5Fields(BackendTester $I, Example $testData)
387 {
388 $this->runInputFieldTest($I, $testData);
389 }
390 }