[TASK] Stabilize acceptance tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / ElementsBasicInputDateCest.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\TestingFramework\Core\Acceptance\Step\Backend\Admin;
18 use TYPO3\TestingFramework\Core\Acceptance\Support\Page\PageTree;
19
20 /**
21 * Tests for "elements_basic" date and time related input fields of ext:styleguide
22 */
23 class ElementsBasicInputDateCest extends AbstractElementsBasicCest
24 {
25 /**
26 * Set up selects styleguide elements basic page and opens record in FormEngine
27 *
28 * @param Admin $I
29 * @param PageTree $pageTree
30 */
31 public function _before(Admin $I, PageTree $pageTree)
32 {
33 $I->useExistingSession();
34
35 $I->click('List');
36 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
37 $I->switchToContentFrame();
38
39 // Open record and wait until form is ready
40 $I->waitForText('elements basic', 20);
41 $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_basic a[data-original-title="Edit record"]';
42 $I->click($editRecordLinkCssPath);
43 $I->waitForElementNotVisible('#t3js-ui-block');
44 $I->waitForText('Edit Form', 3, 'h1');
45 $I->click('inputDateTime');
46 $I->waitForText('inputDateTime', 3);
47 }
48
49 /**
50 * @param Admin $I
51 */
52 public function checkThatValidationWorks_EvalDate_TypeDate(Admin $I)
53 {
54 $dataSets = [
55 'inputdatetime_2 dbType=date eval=date' => [
56 [
57 'inputValue' => '29-01-2016',
58 'expectedValue' => '29-01-2016',
59 'expectedInternalValue' => '2016-01-29T00:00:00Z',
60 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00',
61 'comment' => '',
62 ],
63 [
64 'inputValue' => '13-13-2016',
65 'expectedValue' => '13-01-2017',
66 'expectedInternalValue' => '2017-01-13T00:00:00Z',
67 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00',
68 'comment' => '',
69 ],
70 [
71 'inputValue' => '29-02-2016',
72 'expectedValue' => '29-02-2016',
73 'expectedInternalValue' => '2016-02-29T00:00:00Z',
74 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00',
75 'comment' => 'Check valid leap year input',
76 ],
77 [
78 'inputValue' => '29-02-2015',
79 'expectedValue' => '01-03-2015',
80 'expectedInternalValue' => '2015-03-01T00:00:00Z',
81 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00',
82 'comment' => 'Check invalid leap year transformation',
83 ],
84 ]
85 ];
86 $this->runTests($I, $dataSets);
87 }
88
89 /**
90 * @param Admin $I
91 */
92 public function checkThatValidationWorks_EvalDateTime(Admin $I)
93 {
94 $dataSets = [
95 'inputdatetime_3 eval=datetime' => [
96 [
97 'inputValue' => '05:23 29-01-2016',
98 'expectedValue' => '05:23 29-01-2016',
99 'expectedInternalValue' => '2016-01-29T05:23:00Z',
100 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00',
101 'comment' => '',
102 ],
103 [
104 'inputValue' => '05:23 13-13-2016',
105 'expectedValue' => '05:23 13-01-2017',
106 'expectedInternalValue' => '2017-01-13T05:23:00Z',
107 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00',
108 'comment' => '',
109 ],
110 [
111 'inputValue' => '05:23 29-02-2016',
112 'expectedValue' => '05:23 29-02-2016',
113 'expectedInternalValue' => '2016-02-29T05:23:00Z',
114 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00',
115 'comment' => 'Check valid leap year input',
116 ],
117 [
118 'inputValue' => '05:23 29-02-2015',
119 'expectedValue' => '05:23 01-03-2015',
120 'expectedInternalValue' => '2015-03-01T05:23:00Z',
121 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00',
122 'comment' => 'Check invalid leap year transformation',
123 ],
124 ]
125 ];
126 $this->runTests($I, $dataSets);
127 }
128
129 /**
130 * @param Admin $I
131 */
132 public function checkThatValidationWorks_evalTime(Admin $I)
133 {
134 $dataSets = [
135 'inputdatetime_5' => [
136 [
137 'inputValue' => '13:30',
138 'expectedValue' => '13:30',
139 'expectedInternalValue' => '1970-01-01T13:30:00Z',
140 'expectedValueAfterSave' => '1970-01-01T13:30:00+00:00',
141 'comment' => '',
142 ],
143 [
144 'inputValue' => '123',
145 'expectedValue' => '12:03',
146 'expectedInternalValue' => '1970-01-01T12:03:00Z',
147 'expectedValueAfterSave' => '1970-01-01T12:03:00+00:00',
148 'comment' => '',
149 ],
150 [
151 'inputValue' => '12345',
152 'expectedValue' => '12:34',
153 'expectedInternalValue' => '1970-01-01T12:34:00Z',
154 'expectedValueAfterSave' => '1970-01-01T12:34:00+00:00',
155 'comment' => '',
156 ],
157 [
158 'inputValue' => '12:04+5',
159 'expectedValue' => '12:09',
160 'expectedInternalValue' => '1970-01-01T12:09:00Z',
161 'expectedValueAfterSave' => '1970-01-01T12:09:00+00:00',
162 'comment' => '',
163 ],
164 [
165 'inputValue' => '12:09-3',
166 'expectedValue' => '12:06',
167 'expectedInternalValue' => '1970-01-01T12:06:00Z',
168 'expectedValueAfterSave' => '1970-01-01T12:06:00+00:00',
169 'comment' => '',
170 ],
171 ],
172 ];
173 $this->runTests($I, $dataSets);
174 }
175
176 /**
177 * @param Admin $I
178 */
179 /*
180 public function checkThatValidationWorks_EvalDateTime_DbTypeDateTime(Admin $I)
181 {
182 // @todo fix these unstable test
183 $dataSets = [
184 'input_37 dbType=datetime eval=datetime' => [
185 [
186 'inputValue' => '05:23 29-01-2016',
187 'expectedValue' => '05:23 29-01-2016',
188 'expectedInternalValue' => '2016-01-29T05:23:00Z',
189 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00',
190 'comment' => '',
191 ],
192 [
193 'inputValue' => '05:23 13-13-2016',
194 'expectedValue' => '05:23 13-01-2017',
195 'expectedInternalValue' => '2017-01-13T05:23:00Z',
196 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00',
197 'comment' => '',
198 ],
199 [
200 'inputValue' => '05:23 29-02-2016',
201 'expectedValue' => '05:23 29-02-2016',
202 'expectedInternalValue' => '2016-02-29T05:23:00Z',
203 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00',
204 'comment' => 'Check valid leap year input',
205 ],
206 [
207 'inputValue' => '05:23 29-02-2015',
208 'expectedValue' => '05:23 01-03-2015',
209 'expectedInternalValue' => '2015-03-01T05:23:00Z',
210 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00',
211 'comment' => 'Check invalid leap year transformation',
212 ],
213 ],
214 'input_18 eval=timesec' => [
215 [
216 'inputValue' => '13:30:00',
217 'expectedValue' => '13:30:00',
218 'expectedInternalValue' => '13:30:00',
219 'expectedValueAfterSave' => (new \DateTime('13:30:00'))->getTimestamp(),
220 'comment' => '',
221 ],
222 [
223 'inputValue' => '12345',
224 'expectedValue' => '12:34:05',
225 'expectedInternalValue' => '12:34:05',
226 'expectedValueAfterSave' => (new \DateTime('12:34:05'))->getTimestamp(),
227 'comment' => '',
228 ],
229 [
230 'inputValue' => '12:04:04+5',
231 'expectedValue' => '12:09:04',
232 'expectedInternalValue' => '12:09:04',
233 'expectedValueAfterSave' => (new \DateTime('12:09:04'))->getTimestamp(),
234 'comment' => '',
235 ],
236 ],
237 'input_6 eval=date' => [
238 [
239 'inputValue' => '29-01-2016',
240 'expectedValue' => '29-01-2016',
241 'expectedInternalValue' => '2016-01-29T00:00:00Z',
242 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00',
243 'comment' => '',
244 ],
245 [
246 'inputValue' => '13-13-2016',
247 'expectedValue' => '13-01-2017',
248 'expectedInternalValue' => '2017-01-13T00:00:00Z',
249 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00',
250 'comment' => '',
251 ],
252 [
253 'inputValue' => '29-02-2016',
254 'expectedValue' => '29-02-2016',
255 'expectedInternalValue' => '2016-02-29T00:00:00Z',
256 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00',
257 'comment' => 'Check valid leap year input',
258 ],
259 [
260 'inputValue' => '29-02-2015',
261 'expectedValue' => '01-03-2015',
262 'expectedInternalValue' => '2015-03-01T00:00:00Z',
263 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00',
264 'comment' => 'Check invalid leap year transformation',
265 ],
266 ],
267 ];
268 $this->runTests($I, $dataSets);
269 }
270 */
271 }