[TASK] Remove old language labels in EXT:setup
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Validator / IntegerValidatorTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Validator;
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 /**
18 * Test case
19 */
20 class IntegerValidatorTest extends AbstractValidatorTest
21 {
22 /**
23 * @var string
24 */
25 protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\IntegerValidator::class;
26
27 public function validateForValidInputHasEmptyErrorResultDataProvider()
28 {
29 return [
30 '12 for de locale' => [
31 12,
32 'de_DE.utf8'
33 ],
34 ];
35 }
36
37 /**
38 * @test
39 * @dataProvider validateForValidInputHasEmptyErrorResultDataProvider
40 */
41 public function validateForValidInputHasEmptyErrorResult($value, $locale)
42 {
43 try {
44 $this->setLocale(LC_NUMERIC, $locale);
45 } catch (\PHPUnit_Framework_Exception $e) {
46 $this->markTestSkipped('Locale ' . $locale . ' is not available.');
47 }
48
49 $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
50 $subject = $this->createSubject($options);
51
52 $this->assertEmpty(
53 $subject->validate($value)->getErrors()
54 );
55 }
56
57 public function validateForInvalidInputHasNotEmptyErrorResultDataProvider()
58 {
59 return [
60 '12.1 for en_US locale' => [
61 12.1,
62 'en_US.utf8'
63 ],
64 '12,1 for de_DE locale' => [
65 '12,1',
66 'de_DE.utf8'
67 ],
68 ];
69 }
70
71 /**
72 * @test
73 * @dataProvider validateForInvalidInputHasNotEmptyErrorResultDataProvider
74 */
75 public function validateForInvalidInputHasNotEmptyErrorResult($value, $locale)
76 {
77 try {
78 $this->setLocale(LC_NUMERIC, $locale);
79 } catch (\PHPUnit_Framework_Exception $e) {
80 $this->markTestSkipped('Locale ' . $locale . ' is not available.');
81 }
82
83 $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
84 $subject = $this->createSubject($options);
85
86 $this->assertNotEmpty(
87 $subject->validate($value)->getErrors()
88 );
89 }
90 }