[TASK] Stabilize acceptance tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Formhandler / ElementsBasicInputCest.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" simple input fields of ext:styleguide
22 */
23 class ElementsBasicInputCest 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 $I->click('List');
35 $pageTree->openPath(['styleguide TCA demo', 'elements basic']);
36 $I->switchToContentFrame();
37
38 // Open record and wait until form is ready
39 $I->waitForText('elements basic', 20);
40 $editRecordLinkCssPath = '#recordlist-tx_styleguide_elements_basic a[data-original-title="Edit record"]';
41 $I->click($editRecordLinkCssPath);
42 $I->waitForElementNotVisible('#t3js-ui-block');
43 $I->waitForText('Edit Form', 3, 'h1');
44 }
45
46 /**
47 * @param Admin $I
48 */
49 public function testFieldHandlingOfSimpleFields(Admin $I)
50 {
51 $dataSets = [
52 'input_1' => [
53 [
54 'inputValue' => 'This is a demo text',
55 'expectedValue' => 'This is a demo text',
56 'expectedInternalValue' => 'This is a demo text',
57 'expectedValueAfterSave' => 'This is a demo text',
58 'comment' => '',
59 ],
60 ],
61 'input_2, size=10' => [
62 [
63 'inputValue' => 'This is a demo text with numbers and other characters 42 #!',
64 'expectedValue' => 'This is a demo text with numbers and other characters 42 #!',
65 'expectedInternalValue' => 'This is a demo text with numbers and other characters 42 #!',
66 'expectedValueAfterSave' => 'This is a demo text with numbers and other characters 42 #!',
67 'comment' => '',
68 ],
69 ],
70 'input_3 max=4' => [
71 [
72 'inputValue' => 'Kasper',
73 'expectedValue' => 'Kasp',
74 'expectedInternalValue' => 'Kasp',
75 'expectedValueAfterSave' => 'Kasp',
76 'comment' => '',
77 ],
78 ],
79 'input_4 eval=alpha' => [
80 [
81 'inputValue' => 'Kasper = TYPO3',
82 'expectedValue' => 'KasperTYPO',
83 'expectedInternalValue' => 'KasperTYPO',
84 'expectedValueAfterSave' => 'KasperTYPO',
85 'comment' => '',
86 ],
87 [
88 'inputValue' => 'Non-latin characters: ŠĐŽĆČ',
89 'expectedValue' => 'Nonlatincharacters',
90 'expectedInternalValue' => 'Nonlatincharacters',
91 'expectedValueAfterSave' => 'Nonlatincharacters',
92 'comment' => '',
93 ],
94 ],
95 'input_5 eval=alphanum' => [
96 [
97 'inputValue' => 'Kasper = TYPO3',
98 'expectedValue' => 'KasperTYPO3',
99 'expectedInternalValue' => 'KasperTYPO3',
100 'expectedValueAfterSave' => 'KasperTYPO3',
101 'comment' => '',
102 ],
103 ],
104 'input_10 eval=is_in, is_in=abc123' => [
105 [
106 'inputValue' => 'abcd1234',
107 'expectedValue' => 'abc123',
108 'expectedInternalValue' => 'abc123',
109 'expectedValueAfterSave' => 'abc123',
110 'comment' => '',
111 ],
112 [
113 'inputValue' => 'Kasper TYPO3',
114 'expectedValue' => 'a3',
115 'expectedInternalValue' => 'a3',
116 'expectedValueAfterSave' => 'a3',
117 'comment' => '',
118 ],
119 ],
120 'input_11 eval=lower' => [
121 [
122 'inputValue' => 'Kasper TYPO3!',
123 'expectedValue' => 'kasper typo3!',
124 'expectedInternalValue' => 'kasper typo3!',
125 'expectedValueAfterSave' => 'kasper typo3!',
126 'comment' => '',
127 ],
128 ],
129 'input_13 eval=nospace' => [
130 [
131 'inputValue' => ' Kasper TYPO3! ',
132 'expectedValue' => 'KasperTYPO3!',
133 'expectedInternalValue' => 'KasperTYPO3!',
134 'expectedValueAfterSave' => 'KasperTYPO3!',
135 'comment' => '',
136 ],
137 ],
138 'input_16 eval=password' => [
139 [
140 'inputValue' => 'Kasper',
141 'expectedValue' => '********',
142 'expectedInternalValue' => 'Kasper',
143 'expectedValueAfterSave' => 'Kasper',
144 'comment' => '',
145 ],
146 ],
147 'input_19 eval=trim' => [
148 [
149 'inputValue' => ' Kasper ',
150 'expectedValue' => 'Kasper',
151 'expectedInternalValue' => 'Kasper',
152 'expectedValueAfterSave' => 'Kasper',
153 'comment' => '',
154 ],
155 [
156 'inputValue' => ' Kasper TYPO3 ',
157 'expectedValue' => 'Kasper TYPO3',
158 'expectedInternalValue' => 'Kasper TYPO3',
159 'expectedValueAfterSave' => 'Kasper TYPO3',
160 'comment' => '',
161 ],
162 ],
163 'input_23 eval=upper' => [
164 [
165 'inputValue' => 'Kasper TYPO3!',
166 'expectedValue' => 'KASPER TYPO3!',
167 'expectedInternalValue' => 'KASPER TYPO3!',
168 'expectedValueAfterSave' => 'KASPER TYPO3!',
169 'comment' => '',
170 ],
171 ],
172 'input_24 eval=year' => [
173 [
174 'inputValue' => '2016',
175 'expectedValue' => '2016',
176 'expectedInternalValue' => '2016',
177 'expectedValueAfterSave' => '2016',
178 'comment' => '',
179 ],
180 [
181 'inputValue' => '12',
182 'expectedValue' => '12',
183 'expectedInternalValue' => '12',
184 'expectedValueAfterSave' => '12',
185 'comment' => '',
186 ],
187 [
188 'inputValue' => 'Kasper',
189 'expectedValue' => date('Y'),
190 'expectedInternalValue' => date('Y'),
191 'expectedValueAfterSave' => date('Y'),
192 'comment' => 'Invalid character is converted to current year',
193 ],
194 ]
195 ];
196 $this->runTests($I, $dataSets);
197 }
198
199 /**
200 * @param Admin $I
201 */
202 public function testHandlingOfEvalFields(Admin $I)
203 {
204 $dataSets = [
205 'input_8 eval=double2' => [
206 [
207 'inputValue' => '12.335',
208 'expectedValue' => '12.34',
209 'expectedInternalValue' => '12.34',
210 'expectedValueAfterSave' => '12.34',
211 'comment' => '',
212 ],
213 [
214 'inputValue' => '12,335', // comma as delimiter
215 'expectedValue' => '12.34',
216 'expectedInternalValue' => '12.34',
217 'expectedValueAfterSave' => '12.34',
218 'comment' => '',
219 ],
220 [
221 'inputValue' => '1.1', // comma as delimiter
222 'expectedValue' => '1.10',
223 'expectedInternalValue' => '1.10',
224 'expectedValueAfterSave' => '1.10',
225 'comment' => '',
226 ],
227 [
228 'inputValue' => 'TYPO3', // comma as delimiter
229 'expectedValue' => '3.00',
230 'expectedInternalValue' => '3.00',
231 'expectedValueAfterSave' => '3.00',
232 'comment' => '',
233 ],
234 [
235 'inputValue' => '3TYPO', // comma as delimiter
236 'expectedValue' => '3.00',
237 'expectedInternalValue' => '3.00',
238 'expectedValueAfterSave' => '3.00',
239 'comment' => '',
240 ],
241 ],
242 'input_9 eval=int' => [
243 [
244 'inputValue' => '12.335',
245 'expectedValue' => '12',
246 'expectedInternalValue' => '12',
247 'expectedValueAfterSave' => '12',
248 'comment' => '',
249 ],
250 [
251 'inputValue' => '12,9',
252 'expectedValue' => '12',
253 'expectedInternalValue' => '12',
254 'expectedValueAfterSave' => '12',
255 'comment' => '',
256 ],
257 [
258 'inputValue' => 'TYPO3',
259 'expectedValue' => '0',
260 'expectedInternalValue' => '0',
261 'expectedValueAfterSave' => '0',
262 'comment' => '',
263 ],
264 [
265 'inputValue' => '3TYPO',
266 'expectedValue' => '3',
267 'expectedInternalValue' => '3',
268 'expectedValueAfterSave' => '3',
269 'comment' => '',
270 ],
271 ],
272 'input_15 eval=num' => [
273 [
274 'inputValue' => '12.335',
275 'expectedValue' => '12335',
276 'expectedInternalValue' => '12335',
277 'expectedValueAfterSave' => '12335',
278 'comment' => '',
279 ],
280 [
281 'inputValue' => '12,9',
282 'expectedValue' => '129',
283 'expectedInternalValue' => '129',
284 'expectedValueAfterSave' => '129',
285 'comment' => '',
286 ],
287 [
288 'inputValue' => 'TYPO3',
289 'expectedValue' => '3',
290 'expectedInternalValue' => '3',
291 'expectedValueAfterSave' => '3',
292 'comment' => '',
293 ],
294 [
295 'inputValue' => '3TYPO',
296 'expectedValue' => '3',
297 'expectedInternalValue' => '3',
298 'expectedValueAfterSave' => '3',
299 'comment' => '',
300 ],
301 ],
302 ];
303 $this->runTests($I, $dataSets);
304 }
305
306 /**
307 * @param Admin $I
308 */
309 public function testHandlingOfRangeAndMd5Fields(Admin $I)
310 {
311 $dataSets = [
312 'input_25 eval=int, default=0, range lower=-2, range upper=2' => [
313 [
314 'inputValue' => 'Kasper TYPO3',
315 'expectedValue' => '0',
316 'expectedInternalValue' => '0',
317 'expectedValueAfterSave' => '0',
318 'comment' => '',
319 ],
320 [
321 'inputValue' => '2',
322 'expectedValue' => '2',
323 'expectedInternalValue' => '2',
324 'expectedValueAfterSave' => '2',
325 'comment' => '',
326 ],
327 [
328 'inputValue' => '-1',
329 'expectedValue' => '-1',
330 'expectedInternalValue' => '-1',
331 'expectedValueAfterSave' => '-1',
332 'comment' => '',
333 ],
334 ],
335 'input_12 eval=md5' => [
336 [
337 'inputValue' => 'Kasper TYPO3!',
338 'expectedValue' => '748469dd64911af8df8f9a3dcb2c9378',
339 'expectedInternalValue' => '748469dd64911af8df8f9a3dcb2c9378',
340 'expectedValueAfterSave' => '748469dd64911af8df8f9a3dcb2c9378',
341 'comment' => '',
342 ],
343 [
344 'inputValue' => ' Kasper TYPO3! ',
345 'expectedValue' => '792a085606250c47d6ebb8c98804d5b0',
346 'expectedInternalValue' => '792a085606250c47d6ebb8c98804d5b0',
347 'expectedValueAfterSave' => '792a085606250c47d6ebb8c98804d5b0',
348 'comment' => 'Check whitespaces are not trimmed.',
349 ],
350 ],
351 ];
352 $this->runTests($I, $dataSets);
353 }
354 }