[TASK] Remove old language labels in EXT:setup
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Validator / AlphabeticValidatorTest.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 AlphabeticValidatorTest extends AbstractValidatorTest
21 {
22 /**
23 * @var string
24 */
25 protected $subjectClassName = \TYPO3\CMS\Form\Domain\Validator\AlphabeticValidator::class;
26
27 /**
28 * @return array
29 */
30 public function validDataProviderWithoutWhitespace()
31 {
32 return [
33 'ascii without spaces' => ['thisismyinput'],
34 'accents without spaces' => ['éóéàèò'],
35 'umlauts without spaces' => ['üöä'],
36 'empty string' => ['']
37 ];
38 }
39
40 /**
41 * @return array
42 */
43 public function validDataProviderWithWhitespace()
44 {
45 return [
46 'ascii with spaces' => ['This is my input'],
47 'accents with spaces' => ['Sigur Rós'],
48 'umlauts with spaces' => ['Hürriyet Daily News'],
49 'space' => [' '],
50 'empty string' => ['']
51 ];
52 }
53
54 /**
55 * @return array
56 */
57 public function invalidDataProviderWithoutWhitespace()
58 {
59 return [
60 'ascii with dash' => ['my-name'],
61 'accents with underscore' => ['Sigur_Rós'],
62 'umlauts with periods' => ['Hürriyet.Daily.News'],
63 'space' => [' '],
64 ];
65 }
66
67 /**
68 * @return array
69 */
70 public function invalidDataProviderWithWhitespace()
71 {
72 return [
73 'ascii with spaces and dashes' => ['This is my-name'],
74 'accents with spaces and underscores' => ['Listen to Sigur_Rós_Band'],
75 'umlauts with spaces and periods' => ['Go get the Hürriyet.Daily.News']
76 ];
77 }
78
79 /**
80 * @param string $input
81 * @test
82 * @dataProvider validDataProviderWithoutWhitespace
83 */
84 public function validateForValidInputWithoutAllowedWhitespaceHasEmptyErrorResult($input)
85 {
86 $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
87 $subject = $this->createSubject($options);
88
89 $this->assertEmpty(
90 $subject->validate($input)->getErrors()
91 );
92 }
93
94 /**
95 * @param string $input
96 * @test
97 * @dataProvider validDataProviderWithWhitespace
98 */
99 public function validateForValidInputWithWhitespaceAllowedHasEmptyErrorResult($input)
100 {
101 $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error'), 'allowWhiteSpace' => true];
102 $subject = $this->createSubject($options);
103
104 $this->assertEmpty(
105 $subject->validate($input)->getErrors()
106 );
107 }
108
109 /**
110 * @param string $input
111 * @test
112 * @dataProvider invalidDataProviderWithoutWhitespace
113 */
114 public function validateForInvalidInputWithoutAllowedWhitespaceHasNotEmptyErrorResult($input)
115 {
116 $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error')];
117 $subject = $this->createSubject($options);
118
119 $this->assertNotEmpty(
120 $subject->validate($input)->getErrors()
121 );
122 }
123
124 /**
125 * @param string $input
126 * @test
127 * @dataProvider invalidDataProviderWithWhitespace
128 */
129 public function validateForInvalidInputWithWhitespaceAllowedHasNotEmptyErrorResult($input)
130 {
131 $options = ['element' => uniqid('test'), 'errorMessage' => uniqid('error'), 'allowWhiteSpace' => true];
132 $subject = $this->createSubject($options);
133
134 $this->assertNotEmpty(
135 $subject->validate($input)->getErrors()
136 );
137 }
138 }