e5008e320fddc4188b0638968b8b056495109dfd
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / ElementsBasicCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
18 use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Formhandler;
19 use TYPO3\CMS\Core\Tests\Acceptance\Support\Page\PageTree;
20
21 /**
22 * Tests for basic element fields
23 */
24 class ElementsBasicCest
25 {
26 /**
27 * Selector of the record container in the listview
28 * @var string
29 */
30 protected static $listViewRecordSelector = '#recordlist-tx_styleguide_elements_basic';
31
32 public function _before(Admin $I, PageTree $pageTree)
33 {
34 $I->useExistingSession();
35
36 $I->click('List');
37 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
38 $I->switchToIFrame('contentIframe');
39 }
40
41 /**
42 * @param Admin $I
43 * @param Formhandler $formhandler
44 */
45 public function checkThatBrowserSideValidationsWorkAndSaveRecord(Admin $I, Formhandler $formhandler)
46 {
47 $editRecordLinkCssPath = self::$listViewRecordSelector . ' a[data-original-title="Edit record"]';
48 $I->waitForElement($editRecordLinkCssPath, 30);
49 $I->click($editRecordLinkCssPath);
50 $I->waitForText('Edit Form', 3, 'h1');
51
52 $fieldTests = [
53 'input_1' => [
54 'tests' => [
55 [
56 'This is a demo text with 2 numbers #!',
57 'This is a demo text with 2 numbers #!',
58 ],
59 ],
60 'cleared' => [
61 ''
62 ]
63 ],
64 'input_2, size=10' => [
65 'tests' => [
66 [
67 'This is a demo text with 2 numbers #!',
68 'This is a demo text with 2 numbers #!',
69 ],
70 ],
71 'cleared' => [
72 ''
73 ]
74 ],
75 'input_3 max=4' => [
76 'tests' => [
77 [
78 'Kasper',
79 'Kasp',
80 ],
81 ],
82 'cleared' => [
83 ''
84 ]
85 ],
86 'input_4 eval=alpha' => [
87 'tests' => [
88 [
89 'Kasper = TYPO3',
90 'KasperTYPO',
91 ],
92 [
93 'Non-latin characters: ŠĐŽĆČ',
94 'Nonlatincharacters',
95 ],
96 ],
97 'cleared' => [
98 ''
99 ]
100 ],
101 'input_5 eval=alphanum' => [
102 'tests' => [
103 [
104 'Kasper = TYPO3',
105 'KasperTYPO3',
106 ],
107 ],
108 'cleared' => [
109 ''
110 ]
111 ],
112 'input_6 eval=date' => [
113 'tests' => [
114 [
115 '29-01-2016',
116 '29-01-2016',
117 '1454025600',
118 ],
119 [
120 '13-13-2016',
121 '13-01-2017',
122 '1484265600',
123 ],
124 [
125 '29-02-2016',
126 '29-02-2016',
127 '1456704000',
128 false,
129 'Check valid leap year input'
130 ],
131 [
132 '29-02-2015',
133 '01-03-2015',
134 '1425168000',
135 false,
136 'Check invalid leap year transformation'
137 ],
138 ],
139 'cleared' => [
140 '0'
141 ]
142 ],
143 'input_36 dbType=date eval=date' => [
144 'tests' => [
145 [
146 '29-01-2016',
147 '29-01-2016',
148 '1454025600',
149 ],
150 [
151 '13-13-2016',
152 '13-01-2017',
153 '1484265600',
154 ],
155 [
156 '29-02-2016',
157 '29-02-2016',
158 '1456704000',
159 false,
160 'Check valid leap year input'
161 ],
162 [
163 '29-02-2015',
164 '01-03-2015',
165 '1425168000',
166 false,
167 'Check invalid leap year transformation'
168 ],
169 ],
170 'cleared' => [
171 '0'
172 ]
173 ],
174 'input_7 eval=datetime' => [
175 'tests' => [
176 [
177 '05:23 29-01-2016',
178 '05:23 29-01-2016',
179 '1454044980',
180 ],
181 [
182 '05:23 13-13-2016',
183 '05:23 13-01-2017',
184 '1484284980',
185 ],
186 [
187 '05:23 29-02-2016',
188 '05:23 29-02-2016',
189 '1456723380',
190 false,
191 'Check valid leap year input'
192 ],
193 [
194 '05:23 29-02-2015',
195 '05:23 01-03-2015',
196 '1425187380',
197 false,
198 'Check invalid leap year transformation'
199 ],
200 ],
201 'cleared' => [
202 '0'
203 ]
204 ],
205 'input_37 dbType=datetime eval=datetime' => [
206 'tests' => [
207 [
208 '05:23 29-01-2016',
209 '05:23 29-01-2016',
210 '1454044980',
211 ],
212 [
213 '05:23 13-13-2016',
214 '05:23 13-01-2017',
215 '1484284980',
216 ],
217 [
218 '05:23 29-02-2016',
219 '05:23 29-02-2016',
220 '1456723380',
221 false,
222 'Check valid leap year input'
223 ],
224 [
225 '05:23 29-02-2015',
226 '05:23 01-03-2015',
227 '1425187380',
228 false,
229 'Check invalid leap year transformation'
230 ],
231 ],
232 'cleared' => [
233 '0'
234 ]
235 ],
236 'input_8 eval=double2' => [
237 'tests' => [
238 [
239 '12.335',
240 '12.34',
241 '12.34',
242 ],
243 [
244 '12,335',
245 '12.34',
246 '12.34',
247 ],
248 [
249 '1.1',
250 '1.10',
251 '1.10',
252 ],
253 [
254 'TYPO3',
255 '3.00',
256 '3.00',
257 ],
258 [
259 '3TYPO',
260 '3.00',
261 '3.00',
262 ],
263 ],
264 // @todo: add support for null values to the core
265 'cleared' => [
266 '0.00',
267 '0.00',
268 ]
269 ],
270 'input_9 eval=int' => [
271 'tests' => [
272 [
273 '12.335',
274 '12',
275 '12',
276 ],
277 [
278 '12,9',
279 '12',
280 '12',
281 ],
282 [
283 'TYPO3',
284 '0',
285 '0',
286 ],
287 [
288 '3TYPO',
289 '3',
290 '3',
291 ],
292 ],
293 // @todo: add support for null values to the core
294 'cleared' => [
295 '0',
296 '0',
297 ]
298 ],
299 'input_10 eval=is_in, is_in=abc123' => [
300 'tests' => [
301 [
302 'abcd1234',
303 'abc123',
304 ],
305 [
306 'Kasper TYPO3',
307 'a3',
308 ],
309 ],
310 'cleared' => [
311 '',
312 ]
313 ],
314 'input_11 eval=lower' => [
315 'tests' => [
316 [
317 'Kasper TYPO3!',
318 'kasper typo3!',
319 ],
320 ],
321 'cleared' => [
322 '',
323 ]
324 ],
325 'input_12 eval=md5' => [
326 'tests' => [
327 [
328 'Kasper TYPO3!',
329 '748469dd64911af8df8f9a3dcb2c9378',
330 '748469dd64911af8df8f9a3dcb2c9378',
331 ],
332 [
333 ' Kasper TYPO3! ',
334 '792a085606250c47d6ebb8c98804d5b0',
335 '792a085606250c47d6ebb8c98804d5b0',
336 false,
337 'Check that whitespaces are not trimmed.'
338 ],
339 ],
340 'cleared' => [
341 // @todo: add support for null values to the core
342 // cleared value currently keeps the previous value on save
343 '792a085606250c47d6ebb8c98804d5b0',
344 '792a085606250c47d6ebb8c98804d5b0'
345 ]
346
347 ],
348 'input_13 eval=nospace' => [
349 'tests' => [
350 [
351 ' Kasper TYPO3! ',
352 'KasperTYPO3!',
353 ],
354 ],
355 'cleared' => [
356 '',
357 ]
358 ],
359 // @todo define test
360 //'input_14 eval=null' => [
361 //],
362 'input_15 eval=num' => [
363 'tests' => [
364 [
365 '12.335',
366 '12335',
367 ],
368 [
369 '12,9',
370 '129',
371 ],
372 [
373 'TYPO3',
374 '3',
375 ],
376 [
377 '3TYPO',
378 '3',
379 ],
380 ],
381 'cleared' => [
382 '',
383 ]
384 ],
385 'input_16 eval=password' => [
386 'tests' => [
387 [
388 'Kasper',
389 '********',
390 'Kasper',
391 ],
392 ],
393 'cleared' => [
394 '',
395 ]
396 ],
397 'input_17 eval=time' => [
398 'tests' => [
399 [
400 '13:30',
401 '13:30',
402 '48600',
403 ],
404 [
405 '123',
406 '12:03',
407 '43380',
408 ],
409 [
410 '12345',
411 '12:34',
412 '45240',
413 ],
414 [
415 '12:04+5',
416 '12:09',
417 '43740',
418 ],
419 [
420 '12:09-3',
421 '12:06',
422 '43560',
423 ]
424 ],
425 'cleared' => [
426 '0',
427 '00:00',
428 ]
429 ],
430 'input_18 eval=timesec' => [
431 'tests' => [
432 [
433 '13:30:00',
434 '13:30:00',
435 '48600',
436 ],
437 [
438 '12345',
439 '12:34:05',
440 '45245',
441 ],
442 [
443 // @todo is that the expected behavior?
444 '12:04:04+5',
445 '12:09:04',
446 '43744',
447 ],
448 ],
449 'cleared' => [
450 '0',
451 '00:00:00',
452 ]
453 ],
454 'input_19 eval=trim' => [
455 'tests' => [
456 [
457 ' Kasper ',
458 'Kasper',
459 ],
460 [
461 ' Kasper TYPO3 ',
462 'Kasper TYPO3',
463 ],
464 ],
465 'cleared' => [
466 '',
467 ]
468 ],
469 // @todo Check why this test is currently broken
470 //'input_20 eval with user function' => [
471 // [
472 // 'Kasper',
473 // 'KasperJSfoo',
474 // ]
475 //],
476 'input_23 eval=upper' => [
477 'tests' => [
478 [
479 'Kasper TYPO3!',
480 'KASPER TYPO3!',
481 ],
482 ],
483 'cleared' => [
484 '',
485 ]
486 ],
487 'input_24 eval=year' => [
488 'tests' => [
489
490 [
491 '2016',
492 '2016',
493 '2016',
494 ],
495 [
496 '12',
497 '2012',
498 '2012',
499 ],
500 [
501 'Kasper',
502 date('Y'),
503 date('Y'),
504 false,
505 'Invalid character is converted to current year'
506 ],
507 ],
508 'cleared' => [
509 '0',
510 '0',
511 ]
512 ],
513 'input_25 eval=int, default=0, range lower=-2, range upper=2' => [
514 'tests' => [
515 [
516 'Kasper TYPO3',
517 '0',
518 '0',
519 ],
520 [
521 '2',
522 '2',
523 '2'
524 ],
525 [
526 '-1',
527 '-1',
528 '-1',
529 ],
530 [
531 '-3',
532 '-3',
533 '-3',
534 true,
535 'Expecting a modal with error on trying to save.'
536 ],
537 [
538 '3',
539 '-3',
540 '-3',
541 true,
542 'Expecting a modal with error on trying to save.'
543 ],
544 ],
545 'cleared' => [
546 '0',
547 '0'
548 ]
549 ],
550 ];
551
552 foreach ($fieldTests as $fieldLabel => $testData) {
553 $formhandler->fillSeeSaveAndClearInputField(
554 $fieldLabel,
555 $testData
556 );
557 }
558 }
559 }