TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ElementsBasicCest.php
Go to the documentation of this file.
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 
21 
26 {
32  protected static $listViewRecordSelector = '#recordlist-tx_styleguide_elements_basic';
33 
34  public function _before(Admin $I, PageTree $pageTree)
35  {
36  $I->useExistingSession();
37  // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
38  $I->switchToIFrame('list_frame');
39  $I->waitForText('Web Content Management System');
40  $I->switchToIFrame();
41 
42  $I->click('List');
43  $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
44  $I->switchToIFrame('list_frame');
45  }
46 
52  {
53  $this->waitForFormReady($I);
54 
55  $fieldTests = [
56  'input_1' => [
58  'This is a demo text with 2 numbers #!',
59  'This is a demo text with 2 numbers #!'
60  )
61  ],
62  'input_2, size=10' => [
64  'This is a demo text with 2 numbers #!',
65  'This is a demo text with 2 numbers #!'
66  )
67  ],
68  'input_3 max=4' => [
70  'Kasper',
71  'Kasp'
72  )
73  ],
74  'input_4 eval=alpha' => [
76  'Kasper = TYPO3',
77  'KasperTYPO'
78  ),
80  'Non-latin characters: ŠĐŽĆČ',
81  'Nonlatincharacters'
82  ),
83  ],
84  'input_5 eval=alphanum' => [
86  'Kasper = TYPO3',
87  'KasperTYPO3'
88  ),
89 
90  ],
91  'input_8 eval=double2' => [
93  '12.335',
94  '12.34',
95  '12.34'
96  ),
98  '12,335',
99  '12.34',
100  '12.34'
101  ),
103  '1.1',
104  '1.10',
105  '1.10'
106  ),
108  'TYPO3',
109  '3.00',
110  '3.00'
111  ),
113  '3TYPO',
114  '3.00',
115  '3.00'
116  )
117  ],
118  'input_9 eval=int' => [
120  '12.335',
121  '12',
122  '12'
123 
124  ),
126  '12,9',
127  '12',
128  '12'
129  ),
131  'TYPO3',
132  '0',
133  '0'
134  ),
136  '3TYPO',
137  '3',
138  '3'
139  )
140  ],
141  'input_10 eval=is_in, is_in=abc123' => [
143  'abcd1234',
144  'abc123'
145  ),
147  'Kasper TYPO3',
148  'a3'
149  )
150  ],
151  'input_11 eval=lower' => [
153  'Kasper TYPO3!',
154  'kasper typo3!'
155  )
156  ],
157  'input_12 eval=md5' => [
159  'Kasper TYPO3!',
160  '748469dd64911af8df8f9a3dcb2c9378',
161  '748469dd64911af8df8f9a3dcb2c9378'
162  ),
164  ' Kasper TYPO3! ',
165  '792a085606250c47d6ebb8c98804d5b0',
166  '792a085606250c47d6ebb8c98804d5b0',
167  '792a085606250c47d6ebb8c98804d5b0',
168  false,
169  'Check that whitespaces are not trimmed.'
170  )
171  ],
172  'input_13 eval=nospace' => [
174  ' Kasper TYPO3! ',
175  'KasperTYPO3!'
176  )
177  ],
178  'input_15 eval=num' => [
180  '12.335',
181  '12335'
182  ),
184  '12,9',
185  '129'
186  ),
188  'TYPO3',
189  '3'
190  ),
192  '3TYPO',
193  '3'
194  ),
195  ],
196  'input_16 eval=password' => [
198  'Kasper',
199  '********',
200  'Kasper'
201  ),
202  ],
203  'input_19 eval=trim' => [
205  ' Kasper ',
206  'Kasper'
207  ),
209  ' Kasper TYPO3 ',
210  'Kasper TYPO3'
211  ),
212  ],
213  'input_23 eval=upper' => [
215  'Kasper TYPO3!',
216  'KASPER TYPO3!'
217  )
218  ],
219  'input_25 eval=int, default=0, range lower=-2, range upper=2' => [
221  'Kasper TYPO3',
222  '0',
223  '0'
224  ),
226  '2',
227  '2',
228  '2'
229  ),
231  '-1',
232  '-1',
233  '-1'
234  ),
236  '-3',
237  '-3',
238  '-3',
239  '-3',
240  true,
241  'Expecting a modal with error on trying to save.'
242 
243  ),
245  '3',
246  '-3',
247  '-3',
248  '-3',
249  true,
250  'Expecting a modal with error on trying to save.'
251  )
252  ],
253  ];
254 
255  foreach ($fieldTests as $fieldLabel => $testData) {
256  $formhandler->fillSeeSaveAndClearInputField(
257  $fieldLabel,
258  $testData
259  );
260  }
261  }
262 
267  public function checkThatValidationWorks_evalYear(Admin $I, Formhandler $formhandler)
268  {
269  $this->waitForFormReady($I);
270 
271  $testData = [
272  'input_24 eval=year' => [
274  '2016',
275  '2016',
276  '2016'
277  ),
279  '12',
280  '2012',
281  '2012'
282  ),
284  'Kasper',
285  date('Y'),
286  date('Y'),
287  date('Y'),
288  false,
289  'Invalid character is converted to current year'
290  )
291  ]
292  ];
293 
294  $this->runTests($formhandler, $testData);
295  }
296 
302  {
303  $this->waitForFormReady($I);
304  $fieldData = [
305  'input_6 eval=date' => [
307  '29-01-2016',
308  '29-01-2016',
309  '2016-01-29T00:00:00Z',
310  '2016-01-29T00:00:00+00:00'
311  ),
313  '13-13-2016',
314  '13-01-2017',
315  '2017-01-13T00:00:00Z',
316  '2017-01-13T00:00:00+00:00'
317  ),
319  '29-02-2016',
320  '29-02-2016',
321  '2016-02-29T00:00:00Z',
322  '2016-02-29T00:00:00+00:00',
323  false,
324  'Check valid leap year input'
325  ),
327  '29-02-2015',
328  '01-03-2015',
329  '2015-03-01T00:00:00Z',
330  '2015-03-01T00:00:00+00:00',
331  false,
332  'Check invalid leap year transformation'
333  )
334  ]
335  ];
336  $this->runTests($formhandler, $fieldData);
337  }
338 
340  {
341  $this->waitForFormReady($I);
342  $testData = [
343  'input_36 dbType=date eval=date' => [
345  '29-01-2016',
346  '29-01-2016',
347  '2016-01-29T00:00:00Z',
348  '2016-01-29T00:00:00+00:00'
349  ),
351  '13-13-2016',
352  '13-01-2017',
353  '2017-01-13T00:00:00Z',
354  '2017-01-13T00:00:00+00:00'
355  ),
357  '29-02-2016',
358  '29-02-2016',
359  '2016-02-29T00:00:00Z',
360  '2016-02-29T00:00:00+00:00',
361  false,
362  'Check valid leap year input'
363  ),
365  '29-02-2015',
366  '01-03-2015',
367  '2015-03-01T00:00:00Z',
368  '2015-03-01T00:00:00+00:00',
369  false,
370  'Check invalid leap year transformation'
371  ),
372  ]
373  ];
374  $this->runTests($formhandler, $testData);
375  }
376 
377  public function checkThatValidationWorks_EvalDateTime(Admin $I, Formhandler $formhandler)
378  {
379  $this->waitForFormReady($I);
380  $testData = [
381  'input_7 eval=datetime' => [
383  '05:23 29-01-2016',
384  '05:23 29-01-2016',
385  '2016-01-29T05:23:00Z',
386  '2016-01-29T05:23:00+00:00'
387  ),
389  '05:23 13-13-2016',
390  '05:23 13-01-2017',
391  '2017-01-13T05:23:00Z',
392  '2017-01-13T05:23:00+00:00'
393  ),
395  '05:23 29-02-2016',
396  '05:23 29-02-2016',
397  '2016-02-29T05:23:00Z',
398  '2016-02-29T05:23:00+00:00',
399  false,
400  'Check valid leap year input'
401  ),
403  '05:23 29-02-2015',
404  '05:23 01-03-2015',
405  '2015-03-01T05:23:00Z',
406  '2015-03-01T05:23:00+00:00',
407  false,
408  'Check invalid leap year transformation'
409  )
410  ]
411  ];
412  $this->runTests($formhandler, $testData);
413  }
414 
416  {
417  $this->waitForFormReady($I);
418  $testData = [
419  'input_37 dbType=datetime eval=datetime' => [
421  '05:23 29-01-2016',
422  '05:23 29-01-2016',
423  '2016-01-29T05:23:00Z',
424  '2016-01-29T05:23:00+00:00'
425  ),
427  '05:23 13-13-2016',
428  '05:23 13-01-2017',
429  '2017-01-13T05:23:00Z',
430  '2017-01-13T05:23:00+00:00'
431  ),
433  '05:23 29-02-2016',
434  '05:23 29-02-2016',
435  '2016-02-29T05:23:00Z',
436  '2016-02-29T05:23:00+00:00',
437  false,
438  'Check valid leap year input'
439  ),
441  '05:23 29-02-2015',
442  '05:23 01-03-2015',
443  '2015-03-01T05:23:00Z',
444  '2015-03-01T05:23:00+00:00',
445  false,
446  'Check invalid leap year transformation'
447  ),
448  ],
449  ];
450  $this->runTests($formhandler, $testData);
451  }
452 
453  public function checkThatValidationWorks_evalTime(Admin $I, Formhandler $formhandler)
454  {
455  $this->waitForFormReady($I);
456  $testData = [
457  'input_17 eval=time' => [
459  '13:30',
460  '13:30',
461  '13:30',
462  (new \DateTime('13:30'))->getTimestamp()
463  ),
465  '123',
466  '12:03',
467  '12:03',
468  (new \DateTime('12:03'))->getTimestamp()
469  ),
471  '12345',
472  '12:34',
473  '12:34',
474  (new \DateTime('12:34'))->getTimestamp()
475  ),
477  '12:04+5',
478  '12:09',
479  '12:09',
480  (new \DateTime('12:09'))->getTimestamp()
481  ),
483  '12:09-3',
484  '12:06',
485  '12:06',
486  (new \DateTime('12:06'))->getTimestamp()
487  )
488  ],
489  ];
490  $this->runTests($formhandler, $testData);
491  }
492 
493  public function checkThatValidationWorks_evalTimesec(Admin $I, Formhandler $formhandler)
494  {
495  $this->waitForFormReady($I);
496  $testData = [
497  'input_18 eval=timesec' => [
499  '13:30:00',
500  '13:30:00',
501  '13:30:00',
502  (new \DateTime('13:30:00'))->getTimestamp()
503  ),
505  '12345',
506  '12:34:05',
507  '12:34:05',
508  (new \DateTime('12:34:05'))->getTimestamp()
509  ),
511  '12:04:04+5',
512  '12:09:04',
513  '12:09:04',
514  (new \DateTime('12:09:04'))->getTimestamp()
515  )
516  ],
517  ];
518  $this->runTests($formhandler, $testData);
519  }
520 
525  protected function runTests(Formhandler $formhandler, $fieldData)
526  {
527  foreach ($fieldData as $fieldLabel => $testData) {
528  $formhandler->fillSeeSaveAndClearInputField(
529  $fieldLabel,
530  $testData
531  );
532  }
533  }
534 
538  protected function waitForFormReady(Admin $I)
539  {
540  $editRecordLinkCssPath = self::$listViewRecordSelector . ' a[data-original-title="Edit record"]';
541  $I->waitForElement($editRecordLinkCssPath, 30);
542  $I->click($editRecordLinkCssPath);
543  $I->waitForText('Edit Form', 3, 'h1');
544  }
545 }
fillSeeSaveAndClearInputField($fieldLabel, array $testData)
Definition: Formhandler.php:53
checkThatValidationWorks_EvalDateTime_DbTypeDateTime(Admin $I, Formhandler $formhandler)
checkThatBrowserSideValidationsWorkAndSaveRecord(Admin $I, Formhandler $formhandler)