98d1197a45ab472b04638952200d4de8ac403957
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / FormEngine / ElementsBasicInputDateCest.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" date and time related input fields of ext:styleguide
24 */
25 class ElementsBasicInputDateCest 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
37 $I->click('List');
38 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
39 $I->switchToContentFrame();
40
41 // Open record and wait until form is ready
42 $I->waitForText('elements basic', 20);
43 $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_basic a[data-original-title="Edit record"]';
44 $I->click($editRecordLinkCssPath);
45 $I->waitForElementNotVisible('#t3js-ui-block');
46 $I->waitForText('Edit Form', 3, 'h1');
47 $I->click('inputDateTime');
48 $I->waitForText('inputDateTime', 3);
49 }
50
51 /**
52 * dbTypeDateEvalDate data provider
53 */
54 protected function dbTypeDateEvalDateDataProvider()
55 {
56 return [
57 [
58 // @todo: breaks with too small browser size
59 'label' => 'inputdatetime_2 dbType=date eval=date',
60 'inputValue' => '29-01-2016',
61 'expectedValue' => '29-01-2016',
62 'expectedInternalValue' => '2016-01-29T00:00:00Z',
63 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00',
64 'comment' => '',
65 ],
66 [
67 // @todo: breaks with too small browser size
68 'label' => 'inputdatetime_2 dbType=date eval=date',
69 'inputValue' => '13-13-2016',
70 'expectedValue' => '13-01-2017',
71 'expectedInternalValue' => '2017-01-13T00:00:00Z',
72 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00',
73 'comment' => '',
74 ],
75 [
76 // @todo: breaks with too small browser size
77 'label' => 'inputdatetime_2 dbType=date eval=date',
78 'inputValue' => '29-02-2016',
79 'expectedValue' => '29-02-2016',
80 'expectedInternalValue' => '2016-02-29T00:00:00Z',
81 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00',
82 'comment' => 'Check valid leap year input',
83 ],
84 [
85 // @todo: breaks with too small browser size
86 'label' => 'inputdatetime_2 dbType=date eval=date',
87 'inputValue' => '29-02-2015',
88 'expectedValue' => '01-03-2015',
89 'expectedInternalValue' => '2015-03-01T00:00:00Z',
90 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00',
91 'comment' => 'Check invalid leap year transformation',
92 ],
93 ];
94 }
95
96 /**
97 * @dataProvider dbTypeDateEvalDateDataProvider
98 * @param BackendTester $I
99 * @param Example $testData
100 */
101 public function dbTypeDateEvalDate(BackendTester $I, Example $testData)
102 {
103 $this->runInputFieldTest($I, $testData);
104 }
105 /**
106 * dbType date eval datetime data provider
107 */
108 protected function dbTypeDateEvalDatetimeDataProvider()
109 {
110 return [
111 [
112 // @todo: breaks with too small browser size
113 'label' => 'inputdatetime_3 eval=datetime',
114 'inputValue' => '05:23 29-01-2016',
115 'expectedValue' => '05:23 29-01-2016',
116 'expectedInternalValue' => '2016-01-29T05:23:00Z',
117 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00',
118 'comment' => '',
119 ],
120 [
121 // @todo: breaks with too small browser size
122 'label' => 'inputdatetime_3 eval=datetime',
123 'inputValue' => '05:23 13-13-2016',
124 'expectedValue' => '05:23 13-01-2017',
125 'expectedInternalValue' => '2017-01-13T05:23:00Z',
126 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00',
127 'comment' => '',
128 ],
129 [
130 // @todo: breaks with too small browser size
131 'label' => 'inputdatetime_3 eval=datetime',
132 'inputValue' => '05:23 29-02-2016',
133 'expectedValue' => '05:23 29-02-2016',
134 'expectedInternalValue' => '2016-02-29T05:23:00Z',
135 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00',
136 'comment' => 'Check valid leap year input',
137 ],
138 [
139 // @todo: breaks with too small browser size
140 'label' => 'inputdatetime_3 eval=datetime',
141 'inputValue' => '05:23 29-02-2015',
142 'expectedValue' => '05:23 01-03-2015',
143 'expectedInternalValue' => '2015-03-01T05:23:00Z',
144 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00',
145 'comment' => 'Check invalid leap year transformation',
146 ],
147 ];
148 }
149
150 /**
151 * @dataProvider dbTypeDateEvalDatetimeDataProvider
152 * @param BackendTester $I
153 * @param Example $testData
154 */
155 public function dbTypeDateEvalDatetime(BackendTester $I, Example $testData)
156 {
157 $this->runInputFieldTest($I, $testData);
158 }
159
160 /**
161 * db type date eval time data provider
162 */
163 protected function dbTypeDateEvalTimeDataProvider()
164 {
165 return [
166 [
167 // @todo: breaks with too small browser size
168 'label' => 'inputdatetime_5',
169 'inputValue' => '13:30',
170 'expectedValue' => '13:30',
171 'expectedInternalValue' => '1970-01-01T13:30:00Z',
172 'expectedValueAfterSave' => '1970-01-01T13:30:00+00:00',
173 'comment' => '',
174 ],
175 [
176 // @todo: breaks with too small browser size
177 'label' => 'inputdatetime_5',
178 'inputValue' => '123',
179 'expectedValue' => '12:03',
180 'expectedInternalValue' => '1970-01-01T12:03:00Z',
181 'expectedValueAfterSave' => '1970-01-01T12:03:00+00:00',
182 'comment' => '',
183 ],
184 [
185 // @todo: breaks with too small browser size
186 'label' => 'inputdatetime_5',
187 'inputValue' => '12345',
188 'expectedValue' => '12:34',
189 'expectedInternalValue' => '1970-01-01T12:34:00Z',
190 'expectedValueAfterSave' => '1970-01-01T12:34:00+00:00',
191 'comment' => '',
192 ],
193 [
194 // @todo: breaks with too small browser size
195 'label' => 'inputdatetime_5',
196 'inputValue' => '12:04+5',
197 'expectedValue' => '12:09',
198 'expectedInternalValue' => '1970-01-01T12:09:00Z',
199 'expectedValueAfterSave' => '1970-01-01T12:09:00+00:00',
200 'comment' => '',
201 ],
202 [
203 // @todo: breaks with too small browser size
204 'label' => 'inputdatetime_5',
205 'inputValue' => '12:09-3',
206 'expectedValue' => '12:06',
207 'expectedInternalValue' => '1970-01-01T12:06:00Z',
208 'expectedValueAfterSave' => '1970-01-01T12:06:00+00:00',
209 'comment' => '',
210 ],
211 ];
212 }
213
214 /**
215 * @dataProvider dbTypeDateEvalTimeDataProvider
216 * @param BackendTester $I
217 * @param Example $testData
218 */
219 public function dbTypeDateEvalTime(BackendTester $I, Example $testData)
220 {
221 $this->runInputFieldTest($I, $testData);
222 }
223
224 /**
225 * @param BackendTester $I
226 */
227 /*
228 public function checkThatValidationWorks_EvalDateTime_DbTypeDateTime(AcceptanceTester $I)
229 {
230 // @todo fix these unstable test
231 $dataSets = [
232 'input_37 dbType=datetime eval=datetime' => [
233 [
234 'inputValue' => '05:23 29-01-2016',
235 'expectedValue' => '05:23 29-01-2016',
236 'expectedInternalValue' => '2016-01-29T05:23:00Z',
237 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00',
238 'comment' => '',
239 ],
240 [
241 'inputValue' => '05:23 13-13-2016',
242 'expectedValue' => '05:23 13-01-2017',
243 'expectedInternalValue' => '2017-01-13T05:23:00Z',
244 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00',
245 'comment' => '',
246 ],
247 [
248 'inputValue' => '05:23 29-02-2016',
249 'expectedValue' => '05:23 29-02-2016',
250 'expectedInternalValue' => '2016-02-29T05:23:00Z',
251 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00',
252 'comment' => 'Check valid leap year input',
253 ],
254 [
255 'inputValue' => '05:23 29-02-2015',
256 'expectedValue' => '05:23 01-03-2015',
257 'expectedInternalValue' => '2015-03-01T05:23:00Z',
258 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00',
259 'comment' => 'Check invalid leap year transformation',
260 ],
261 ],
262 'input_18 eval=timesec' => [
263 [
264 'inputValue' => '13:30:00',
265 'expectedValue' => '13:30:00',
266 'expectedInternalValue' => '13:30:00',
267 'expectedValueAfterSave' => (new \DateTime('13:30:00'))->getTimestamp(),
268 'comment' => '',
269 ],
270 [
271 'inputValue' => '12345',
272 'expectedValue' => '12:34:05',
273 'expectedInternalValue' => '12:34:05',
274 'expectedValueAfterSave' => (new \DateTime('12:34:05'))->getTimestamp(),
275 'comment' => '',
276 ],
277 [
278 'inputValue' => '12:04:04+5',
279 'expectedValue' => '12:09:04',
280 'expectedInternalValue' => '12:09:04',
281 'expectedValueAfterSave' => (new \DateTime('12:09:04'))->getTimestamp(),
282 'comment' => '',
283 ],
284 ],
285 'input_6 eval=date' => [
286 [
287 'inputValue' => '29-01-2016',
288 'expectedValue' => '29-01-2016',
289 'expectedInternalValue' => '2016-01-29T00:00:00Z',
290 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00',
291 'comment' => '',
292 ],
293 [
294 'inputValue' => '13-13-2016',
295 'expectedValue' => '13-01-2017',
296 'expectedInternalValue' => '2017-01-13T00:00:00Z',
297 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00',
298 'comment' => '',
299 ],
300 [
301 'inputValue' => '29-02-2016',
302 'expectedValue' => '29-02-2016',
303 'expectedInternalValue' => '2016-02-29T00:00:00Z',
304 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00',
305 'comment' => 'Check valid leap year input',
306 ],
307 [
308 'inputValue' => '29-02-2015',
309 'expectedValue' => '01-03-2015',
310 'expectedInternalValue' => '2015-03-01T00:00:00Z',
311 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00',
312 'comment' => 'Check invalid leap year transformation',
313 ],
314 ],
315 ];
316 $this->runTests($I, $dataSets);
317 }
318 */
319 }