371e4465428c175e6cc68aa70a388bf04736ee2b
[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 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
35 $I->switchToIFrame('list_frame');
36 $I->waitForText('Web Content Management System');
37 $I->switchToIFrame();
38
39 $I->click('List');
40 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
41 $I->switchToIFrame('list_frame');
42 $I->waitForElementNotVisible('div#nprogess', 30);
43
44 // Open record and wait until form is ready
45 $I->waitForText('elements basic', 20);
46 $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_basic a[data-original-title="Edit record"]';
47 $I->click($editRecordLinkCssPath);
48 $I->waitForElementNotVisible('#t3js-ui-block');
49 $I->waitForText('Edit Form', 3, 'h1');
50 $I->click('inputDateTime');
51 $I->waitForText('inputDateTime', 3);
52 }
53
54 /**
55 * @param Admin $I
56 */
57 public function checkThatValidationWorks_EvalDate_TypeDate(Admin $I)
58 {
59 $dataSets = [
60 'inputdatetime_2 dbType=date eval=date' => [
61 [
62 'inputValue' => '29-01-2016',
63 'expectedValue' => '29-01-2016',
64 'expectedInternalValue' => '2016-01-29T00:00:00Z',
65 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00',
66 'comment' => '',
67 ],
68 [
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 'inputValue' => '29-02-2016',
77 'expectedValue' => '29-02-2016',
78 'expectedInternalValue' => '2016-02-29T00:00:00Z',
79 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00',
80 'comment' => 'Check valid leap year input',
81 ],
82 [
83 'inputValue' => '29-02-2015',
84 'expectedValue' => '01-03-2015',
85 'expectedInternalValue' => '2015-03-01T00:00:00Z',
86 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00',
87 'comment' => 'Check invalid leap year transformation',
88 ],
89 ]
90 ];
91 $this->runTests($I, $dataSets);
92 }
93
94 /**
95 * @param Admin $I
96 */
97 public function checkThatValidationWorks_EvalDateTime(Admin $I)
98 {
99 $dataSets = [
100 'inputdatetime_3 eval=datetime' => [
101 [
102 'inputValue' => '05:23 29-01-2016',
103 'expectedValue' => '05:23 29-01-2016',
104 'expectedInternalValue' => '2016-01-29T05:23:00Z',
105 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00',
106 'comment' => '',
107 ],
108 [
109 'inputValue' => '05:23 13-13-2016',
110 'expectedValue' => '05:23 13-01-2017',
111 'expectedInternalValue' => '2017-01-13T05:23:00Z',
112 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00',
113 'comment' => '',
114 ],
115 [
116 'inputValue' => '05:23 29-02-2016',
117 'expectedValue' => '05:23 29-02-2016',
118 'expectedInternalValue' => '2016-02-29T05:23:00Z',
119 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00',
120 'comment' => 'Check valid leap year input',
121 ],
122 [
123 'inputValue' => '05:23 29-02-2015',
124 'expectedValue' => '05:23 01-03-2015',
125 'expectedInternalValue' => '2015-03-01T05:23:00Z',
126 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00',
127 'comment' => 'Check invalid leap year transformation',
128 ],
129 ]
130 ];
131 $this->runTests($I, $dataSets);
132 }
133
134 /**
135 * @param Admin $I
136 */
137 public function checkThatValidationWorks_evalTime(Admin $I)
138 {
139 $dataSets = [
140 'inputdatetime_5' => [
141 [
142 'inputValue' => '13:30',
143 'expectedValue' => '13:30',
144 'expectedInternalValue' => '1970-01-01T13:30:00Z',
145 'expectedValueAfterSave' => '1970-01-01T13:30:00+00:00',
146 'comment' => '',
147 ],
148 [
149 'inputValue' => '123',
150 'expectedValue' => '12:03',
151 'expectedInternalValue' => '1970-01-01T12:03:00Z',
152 'expectedValueAfterSave' => '1970-01-01T12:03:00+00:00',
153 'comment' => '',
154 ],
155 [
156 'inputValue' => '12345',
157 'expectedValue' => '12:34',
158 'expectedInternalValue' => '1970-01-01T12:34:00Z',
159 'expectedValueAfterSave' => '1970-01-01T12:34:00+00:00',
160 'comment' => '',
161 ],
162 [
163 'inputValue' => '12:04+5',
164 'expectedValue' => '12:09',
165 'expectedInternalValue' => '1970-01-01T12:09:00Z',
166 'expectedValueAfterSave' => '1970-01-01T12:09:00+00:00',
167 'comment' => '',
168 ],
169 [
170 'inputValue' => '12:09-3',
171 'expectedValue' => '12:06',
172 'expectedInternalValue' => '1970-01-01T12:06:00Z',
173 'expectedValueAfterSave' => '1970-01-01T12:06:00+00:00',
174 'comment' => '',
175 ],
176 ],
177 ];
178 $this->runTests($I, $dataSets);
179 }
180
181 /**
182 * @param Admin $I
183 */
184 /*
185 public function checkThatValidationWorks_EvalDateTime_DbTypeDateTime(Admin $I)
186 {
187 // @todo fix these unstable test
188 $dataSets = [
189 'input_37 dbType=datetime eval=datetime' => [
190 [
191 'inputValue' => '05:23 29-01-2016',
192 'expectedValue' => '05:23 29-01-2016',
193 'expectedInternalValue' => '2016-01-29T05:23:00Z',
194 'expectedValueAfterSave' => '2016-01-29T05:23:00+00:00',
195 'comment' => '',
196 ],
197 [
198 'inputValue' => '05:23 13-13-2016',
199 'expectedValue' => '05:23 13-01-2017',
200 'expectedInternalValue' => '2017-01-13T05:23:00Z',
201 'expectedValueAfterSave' => '2017-01-13T05:23:00+00:00',
202 'comment' => '',
203 ],
204 [
205 'inputValue' => '05:23 29-02-2016',
206 'expectedValue' => '05:23 29-02-2016',
207 'expectedInternalValue' => '2016-02-29T05:23:00Z',
208 'expectedValueAfterSave' => '2016-02-29T05:23:00+00:00',
209 'comment' => 'Check valid leap year input',
210 ],
211 [
212 'inputValue' => '05:23 29-02-2015',
213 'expectedValue' => '05:23 01-03-2015',
214 'expectedInternalValue' => '2015-03-01T05:23:00Z',
215 'expectedValueAfterSave' => '2015-03-01T05:23:00+00:00',
216 'comment' => 'Check invalid leap year transformation',
217 ],
218 ],
219 'input_18 eval=timesec' => [
220 [
221 'inputValue' => '13:30:00',
222 'expectedValue' => '13:30:00',
223 'expectedInternalValue' => '13:30:00',
224 'expectedValueAfterSave' => (new \DateTime('13:30:00'))->getTimestamp(),
225 'comment' => '',
226 ],
227 [
228 'inputValue' => '12345',
229 'expectedValue' => '12:34:05',
230 'expectedInternalValue' => '12:34:05',
231 'expectedValueAfterSave' => (new \DateTime('12:34:05'))->getTimestamp(),
232 'comment' => '',
233 ],
234 [
235 'inputValue' => '12:04:04+5',
236 'expectedValue' => '12:09:04',
237 'expectedInternalValue' => '12:09:04',
238 'expectedValueAfterSave' => (new \DateTime('12:09:04'))->getTimestamp(),
239 'comment' => '',
240 ],
241 ],
242 'input_6 eval=date' => [
243 [
244 'inputValue' => '29-01-2016',
245 'expectedValue' => '29-01-2016',
246 'expectedInternalValue' => '2016-01-29T00:00:00Z',
247 'expectedValueAfterSave' => '2016-01-29T00:00:00+00:00',
248 'comment' => '',
249 ],
250 [
251 'inputValue' => '13-13-2016',
252 'expectedValue' => '13-01-2017',
253 'expectedInternalValue' => '2017-01-13T00:00:00Z',
254 'expectedValueAfterSave' => '2017-01-13T00:00:00+00:00',
255 'comment' => '',
256 ],
257 [
258 'inputValue' => '29-02-2016',
259 'expectedValue' => '29-02-2016',
260 'expectedInternalValue' => '2016-02-29T00:00:00Z',
261 'expectedValueAfterSave' => '2016-02-29T00:00:00+00:00',
262 'comment' => 'Check valid leap year input',
263 ],
264 [
265 'inputValue' => '29-02-2015',
266 'expectedValue' => '01-03-2015',
267 'expectedInternalValue' => '2015-03-01T00:00:00Z',
268 'expectedValueAfterSave' => '2015-03-01T00:00:00+00:00',
269 'comment' => 'Check invalid leap year transformation',
270 ],
271 ],
272 ];
273 $this->runTests($I, $dataSets);
274 }
275 */
276 }