@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | $_options = []; |
86 | 86 | |
87 | - $options = array_change_key_case(array_filter($options, function ($var) { |
|
87 | + $options = array_change_key_case(array_filter($options, function($var) { |
|
88 | 88 | return !is_null($var); |
89 | 89 | })); |
90 | 90 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if ($attribute == 'required' || $_value == 'required') { |
117 | 117 | $_options['required'] = true; |
118 | 118 | } elseif (in_array($attribute, ['length', 'mincheck', 'maxcheck', 'check', 'equalto'])) { |
119 | - $_options['attr']['data-parsley-' . $attribute] = $_value; |
|
119 | + $_options['attr']['data-parsley-'.$attribute] = $_value; |
|
120 | 120 | } elseif ($attribute == 'range') { |
121 | 121 | $_options['type'] = $attribute; |
122 | 122 | list($min, $max) = explode(',', $_value); |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | private function twig() |
169 | 169 | { |
170 | 170 | $appVariableReflection = new \ReflectionClass('\Symfony\Bridge\Twig\AppVariable'); |
171 | - $vendorTwigBridgeDirectory = dirname((string)$appVariableReflection->getFileName()); |
|
171 | + $vendorTwigBridgeDirectory = dirname((string) $appVariableReflection->getFileName()); |
|
172 | 172 | |
173 | 173 | $loader = new \Twig\Loader\FilesystemLoader([ |
174 | - $vendorTwigBridgeDirectory . '/Resources/views/Form', |
|
174 | + $vendorTwigBridgeDirectory.'/Resources/views/Form', |
|
175 | 175 | ]); |
176 | 176 | |
177 | 177 | $twig = new \Twig\Environment($loader); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $formEngine = new \Symfony\Bridge\Twig\Form\TwigRendererEngine(['bootstrap_4_layout.html.twig'], $twig); |
184 | 184 | $twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader([ |
185 | - \Symfony\Component\Form\FormRenderer::class => function () use ($formEngine) { |
|
185 | + \Symfony\Component\Form\FormRenderer::class => function() use ($formEngine) { |
|
186 | 186 | return new \Symfony\Component\Form\FormRenderer($formEngine); |
187 | 187 | }, |
188 | 188 | ])); |
@@ -32,35 +32,3 @@ |
||
32 | 32 | $render = Input::create($type, 'foo'); |
33 | 33 | |
34 | 34 | $this->assertEquals(<<<'T' |
35 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
36 | -T, $render); |
|
37 | - } |
|
38 | - |
|
39 | - public function testItRenderText(): void |
|
40 | - { |
|
41 | - $render = Input::text('foo'); |
|
42 | - |
|
43 | - $this->assertEquals(<<<'T' |
|
44 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
45 | -T, $render); |
|
46 | - } |
|
47 | - |
|
48 | - public function getTypeNameOptions(): array |
|
49 | - { |
|
50 | - return [ |
|
51 | - ['text'], |
|
52 | - [' text '], |
|
53 | - [' text'], |
|
54 | - ['text '], |
|
55 | - ['TEXT '], |
|
56 | - ['textType'], |
|
57 | - [' textType '], |
|
58 | - [' textType'], |
|
59 | - ['textType '], |
|
60 | - ['TextType '], |
|
61 | - ['Texttype '], |
|
62 | - ['texttype '], |
|
63 | - ['TEXTTYPE '], |
|
64 | - ]; |
|
65 | - } |
|
66 | -} |
@@ -32,35 +32,3 @@ |
||
32 | 32 | $render = Input::create($type, 'foo'); |
33 | 33 | |
34 | 34 | $this->assertEquals(<<<'T' |
35 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
36 | -T, $render); |
|
37 | - } |
|
38 | - |
|
39 | - public function testItRenderText(): void |
|
40 | - { |
|
41 | - $render = Input::text('foo'); |
|
42 | - |
|
43 | - $this->assertEquals(<<<'T' |
|
44 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
45 | -T, $render); |
|
46 | - } |
|
47 | - |
|
48 | - public function getTypeNameOptions(): array |
|
49 | - { |
|
50 | - return [ |
|
51 | - ['text'], |
|
52 | - [' text '], |
|
53 | - [' text'], |
|
54 | - ['text '], |
|
55 | - ['TEXT '], |
|
56 | - ['textType'], |
|
57 | - [' textType '], |
|
58 | - [' textType'], |
|
59 | - ['textType '], |
|
60 | - ['TextType '], |
|
61 | - ['Texttype '], |
|
62 | - ['texttype '], |
|
63 | - ['TEXTTYPE '], |
|
64 | - ]; |
|
65 | - } |
|
66 | -} |
@@ -32,35 +32,3 @@ |
||
32 | 32 | $render = Input::create($type, 'foo'); |
33 | 33 | |
34 | 34 | $this->assertEquals(<<<'T' |
35 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
36 | -T, $render); |
|
37 | - } |
|
38 | - |
|
39 | - public function testItRenderText(): void |
|
40 | - { |
|
41 | - $render = Input::text('foo'); |
|
42 | - |
|
43 | - $this->assertEquals(<<<'T' |
|
44 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
45 | -T, $render); |
|
46 | - } |
|
47 | - |
|
48 | - public function getTypeNameOptions(): array |
|
49 | - { |
|
50 | - return [ |
|
51 | - ['text'], |
|
52 | - [' text '], |
|
53 | - [' text'], |
|
54 | - ['text '], |
|
55 | - ['TEXT '], |
|
56 | - ['textType'], |
|
57 | - [' textType '], |
|
58 | - [' textType'], |
|
59 | - ['textType '], |
|
60 | - ['TextType '], |
|
61 | - ['Texttype '], |
|
62 | - ['texttype '], |
|
63 | - ['TEXTTYPE '], |
|
64 | - ]; |
|
65 | - } |
|
66 | -} |
@@ -32,35 +32,3 @@ |
||
32 | 32 | $render = Input::create($type, 'foo'); |
33 | 33 | |
34 | 34 | $this->assertEquals(<<<'T' |
35 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
36 | -T, $render); |
|
37 | - } |
|
38 | - |
|
39 | - public function testItRenderText(): void |
|
40 | - { |
|
41 | - $render = Input::text('foo'); |
|
42 | - |
|
43 | - $this->assertEquals(<<<'T' |
|
44 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
45 | -T, $render); |
|
46 | - } |
|
47 | - |
|
48 | - public function getTypeNameOptions(): array |
|
49 | - { |
|
50 | - return [ |
|
51 | - ['text'], |
|
52 | - [' text '], |
|
53 | - [' text'], |
|
54 | - ['text '], |
|
55 | - ['TEXT '], |
|
56 | - ['textType'], |
|
57 | - [' textType '], |
|
58 | - [' textType'], |
|
59 | - ['textType '], |
|
60 | - ['TextType '], |
|
61 | - ['Texttype '], |
|
62 | - ['texttype '], |
|
63 | - ['TEXTTYPE '], |
|
64 | - ]; |
|
65 | - } |
|
66 | -} |
@@ -32,35 +32,3 @@ |
||
32 | 32 | $render = Input::create($type, 'foo'); |
33 | 33 | |
34 | 34 | $this->assertEquals(<<<'T' |
35 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
36 | -T, $render); |
|
37 | - } |
|
38 | - |
|
39 | - public function testItRenderText(): void |
|
40 | - { |
|
41 | - $render = Input::text('foo'); |
|
42 | - |
|
43 | - $this->assertEquals(<<<'T' |
|
44 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
45 | -T, $render); |
|
46 | - } |
|
47 | - |
|
48 | - public function getTypeNameOptions(): array |
|
49 | - { |
|
50 | - return [ |
|
51 | - ['text'], |
|
52 | - [' text '], |
|
53 | - [' text'], |
|
54 | - ['text '], |
|
55 | - ['TEXT '], |
|
56 | - ['textType'], |
|
57 | - [' textType '], |
|
58 | - [' textType'], |
|
59 | - ['textType '], |
|
60 | - ['TextType '], |
|
61 | - ['Texttype '], |
|
62 | - ['texttype '], |
|
63 | - ['TEXTTYPE '], |
|
64 | - ]; |
|
65 | - } |
|
66 | -} |
@@ -31,449 +31,3 @@ |
||
31 | 31 | $render = $this->getMock('foo', TextType::class, [])->render(); |
32 | 32 | |
33 | 33 | $this->assertEquals(<<<'T' |
34 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
35 | -T, $render); |
|
36 | - } |
|
37 | - |
|
38 | - public function testItDefaultSlug(): void |
|
39 | - { |
|
40 | - $render = $this->getMock('foo_bar', TextType::class, [])->render(); |
|
41 | - |
|
42 | - $this->assertEquals(<<<'T' |
|
43 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
44 | -T, $render); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @dataProvider getDefaultWithSpacesOptions |
|
49 | - */ |
|
50 | - public function testItDefaultSpace($name): void |
|
51 | - { |
|
52 | - $render = $this->getMock($name, TextType::class, [])->render(); |
|
53 | - |
|
54 | - $this->assertEquals(<<<'T' |
|
55 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
56 | -T, $render); |
|
57 | - } |
|
58 | - |
|
59 | - public function testItSetLabel(): void |
|
60 | - { |
|
61 | - $render = $this->getMock('foo', TextType::class, [ |
|
62 | - 'Label' => 'My Label', |
|
63 | - ])->render(); |
|
64 | - |
|
65 | - $this->assertEquals(<<<'T' |
|
66 | -<div class="form-group"><label for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
67 | -T, $render); |
|
68 | - } |
|
69 | - |
|
70 | - public function testItSetLabelAttr(): void |
|
71 | - { |
|
72 | - $render = $this->getMock('foo', TextType::class, [ |
|
73 | - 'Label' => 'My Label', |
|
74 | - 'label_attr' => [ |
|
75 | - 'class' => 'label-class', |
|
76 | - ], |
|
77 | - ])->render(); |
|
78 | - |
|
79 | - $this->assertEquals(<<<'T' |
|
80 | -<div class="form-group"><label class="label-class" for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
81 | -T, $render); |
|
82 | - } |
|
83 | - |
|
84 | - public function testItSetDefault(): void |
|
85 | - { |
|
86 | - $render = $this->getMock('foo', TextType::class, [ |
|
87 | - 'Default' => 'fuz', |
|
88 | - ])->render(); |
|
89 | - |
|
90 | - $this->assertEquals(<<<'T' |
|
91 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" value="fuz" /></div> |
|
92 | -T, $render); |
|
93 | - } |
|
94 | - |
|
95 | - public function testItSetType(): void |
|
96 | - { |
|
97 | - $render = $this->getMock('foo', TextType::class, [ |
|
98 | - 'Type' => 'email', |
|
99 | - ])->render(); |
|
100 | - |
|
101 | - $this->assertEquals(<<<'T' |
|
102 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
103 | -T, $render); |
|
104 | - } |
|
105 | - |
|
106 | - public function testItSetRequired(): void |
|
107 | - { |
|
108 | - $render = $this->getMock('foo', TextType::class, [ |
|
109 | - 'required' => true, |
|
110 | - ])->render(); |
|
111 | - |
|
112 | - $this->assertEquals(<<<'T' |
|
113 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
114 | -T, $render); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @dataProvider getRequiredOptions |
|
119 | - * |
|
120 | - * @param string|array $required |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function testItSetRequiredConstraint($required): void |
|
124 | - { |
|
125 | - $render = $this->getMock('foo', TextType::class, [ |
|
126 | - 'Constraints' => $required, |
|
127 | - ])->render(); |
|
128 | - |
|
129 | - $this->assertEquals(<<<'T' |
|
130 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
131 | -T, $render); |
|
132 | - } |
|
133 | - |
|
134 | - public function testItSetTypeConstraint(): void |
|
135 | - { |
|
136 | - $render = $this->getMock('foo', TextType::class, [ |
|
137 | - 'Constraints' => json_encode([ |
|
138 | - 'type' => 'email', |
|
139 | - ]), |
|
140 | - ])->render(); |
|
141 | - |
|
142 | - $this->assertEquals(<<<'T' |
|
143 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
144 | -T, $render); |
|
145 | - } |
|
146 | - |
|
147 | - public function testItSetTypeAttrConstraint(): void |
|
148 | - { |
|
149 | - $render = $this->getMock('foo', TextType::class, [ |
|
150 | - 'attr' => [ |
|
151 | - 'type' => 'email', |
|
152 | - ], |
|
153 | - ])->render(); |
|
154 | - |
|
155 | - $this->assertEquals(<<<'T' |
|
156 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
157 | -T, $render); |
|
158 | - } |
|
159 | - |
|
160 | - public function testItSetDigitsConstraint(): void |
|
161 | - { |
|
162 | - $render = $this->getMock('foo', TextType::class, [ |
|
163 | - 'Constraints' => json_encode([ |
|
164 | - 'type' => 'digits', |
|
165 | - ]), |
|
166 | - ])->render(); |
|
167 | - |
|
168 | - $this->assertEquals(<<<'T' |
|
169 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="digits" class="form-control" /></div> |
|
170 | -T, $render); |
|
171 | - } |
|
172 | - |
|
173 | - public function testItSetAlphanumConstraint(): void |
|
174 | - { |
|
175 | - $render = $this->getMock('foo', TextType::class, [ |
|
176 | - 'Constraints' => json_encode([ |
|
177 | - 'Type' => 'Alphanum', |
|
178 | - ]), |
|
179 | - ])->render(); |
|
180 | - |
|
181 | - $this->assertEquals(<<<'T' |
|
182 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="alphanum" class="form-control" /></div> |
|
183 | -T, $render); |
|
184 | - } |
|
185 | - |
|
186 | - public function testItSetMinLengthConstraint(): void |
|
187 | - { |
|
188 | - $render = $this->getMock('foo', TextType::class, [ |
|
189 | - 'Constraints' => json_encode([ |
|
190 | - 'minlength' => 5, |
|
191 | - ]), |
|
192 | - ])->render(); |
|
193 | - |
|
194 | - $this->assertEquals(<<<'T' |
|
195 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" minlength="5" class="form-control" /></div> |
|
196 | -T, $render); |
|
197 | - } |
|
198 | - |
|
199 | - public function testItSetMaxLengthConstraint(): void |
|
200 | - { |
|
201 | - $render = $this->getMock('foo', TextType::class, [ |
|
202 | - 'Constraints' => json_encode([ |
|
203 | - 'maxlength' => 666, |
|
204 | - ]), |
|
205 | - ])->render(); |
|
206 | - |
|
207 | - $this->assertEquals(<<<'T' |
|
208 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" maxlength="666" class="form-control" /></div> |
|
209 | -T, $render); |
|
210 | - } |
|
211 | - |
|
212 | - public function testItSetLengthConstraint(): void |
|
213 | - { |
|
214 | - $render = $this->getMock('foo', TextType::class, [ |
|
215 | - 'Constraints' => json_encode([ |
|
216 | - 'length' => '[6,10]', |
|
217 | - ]), |
|
218 | - ])->render(); |
|
219 | - |
|
220 | - $this->assertEquals(<<<'T' |
|
221 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-length="[6,10]" class="form-control" /></div> |
|
222 | -T, $render); |
|
223 | - } |
|
224 | - |
|
225 | - public function testItSetMinConstraint(): void |
|
226 | - { |
|
227 | - $render = $this->getMock('foo', TextType::class, [ |
|
228 | - 'Constraints' => json_encode([ |
|
229 | - 'min' => 3, |
|
230 | - ]), |
|
231 | - ])->render(); |
|
232 | - |
|
233 | - $this->assertEquals(<<<'T' |
|
234 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" min="3" class="form-control" /></div> |
|
235 | -T, $render); |
|
236 | - } |
|
237 | - |
|
238 | - public function testItSetMaxConstraint(): void |
|
239 | - { |
|
240 | - $render = $this->getMock('foo', TextType::class, [ |
|
241 | - 'Constraints' => json_encode([ |
|
242 | - 'max' => 99, |
|
243 | - ]), |
|
244 | - ])->render(); |
|
245 | - |
|
246 | - $this->assertEquals(<<<'T' |
|
247 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" max="99" class="form-control" /></div> |
|
248 | -T, $render); |
|
249 | - } |
|
250 | - |
|
251 | - public function testItSetRangeConstraint(): void |
|
252 | - { |
|
253 | - $render = $this->getMock('foo', TextType::class, [ |
|
254 | - 'Constraints' => json_encode([ |
|
255 | - 'range' => '6,10', |
|
256 | - ]), |
|
257 | - ])->render(); |
|
258 | - |
|
259 | - $this->assertEquals(<<<'T' |
|
260 | -<div class="form-group"><label for="form_foo">Foo</label> <input type="range" id="form_foo" name="form[foo]" min="6" max="10" class="form-control" /></div> |
|
261 | -T, $render); |
|
262 | - } |
|
263 | - |
|
264 | - public function testItSetPatternConstraint(): void |
|
265 | - { |
|
266 | - $render = $this->getMock('foo', TextType::class, [ |
|
267 | - 'Constraints' => json_encode([ |
|
268 | - 'pattern' => "\+d", |
|
269 | - ]), |
|
270 | - ])->render(); |
|
271 | - |
|
272 | - $this->assertEquals(<<<'T' |
|
273 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" pattern="\+d" class="form-control" /></div> |
|
274 | -T, $render); |
|
275 | - } |
|
276 | - |
|
277 | - public function testItSetMinCheckConstraint(): void |
|
278 | - { |
|
279 | - $render = $this->getMock('foo', TextType::class, [ |
|
280 | - 'Constraints' => json_encode([ |
|
281 | - 'mincheck' => '3', |
|
282 | - ]), |
|
283 | - ])->render(); |
|
284 | - |
|
285 | - $this->assertEquals(<<<'T' |
|
286 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-mincheck="3" class="form-control" /></div> |
|
287 | -T, $render); |
|
288 | - } |
|
289 | - |
|
290 | - public function testItSetMaxCheckConstraint(): void |
|
291 | - { |
|
292 | - $render = $this->getMock('foo', TextType::class, [ |
|
293 | - 'Constraints' => json_encode([ |
|
294 | - 'maxcheck' => 5, |
|
295 | - ]), |
|
296 | - ])->render(); |
|
297 | - |
|
298 | - $this->assertEquals(<<<'T' |
|
299 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-maxcheck="5" class="form-control" /></div> |
|
300 | -T, $render); |
|
301 | - } |
|
302 | - |
|
303 | - public function testItSetCheckConstraint(): void |
|
304 | - { |
|
305 | - $render = $this->getMock('foo', TextType::class, [ |
|
306 | - 'Constraints' => json_encode([ |
|
307 | - 'check' => '[1,3]', |
|
308 | - ]), |
|
309 | - ])->render(); |
|
310 | - |
|
311 | - $this->assertEquals(<<<'T' |
|
312 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-check="[1,3]" class="form-control" /></div> |
|
313 | -T, $render); |
|
314 | - } |
|
315 | - |
|
316 | - public function testItSetEqualToConstraint(): void |
|
317 | - { |
|
318 | - $render = $this->getMock('foo', TextType::class, [ |
|
319 | - 'Constraints' => json_encode([ |
|
320 | - 'equalto' => '#another', |
|
321 | - ]), |
|
322 | - ])->render(); |
|
323 | - |
|
324 | - $this->assertEquals(<<<'T' |
|
325 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-equalto="#another" class="form-control" /></div> |
|
326 | -T, $render); |
|
327 | - } |
|
328 | - |
|
329 | - public function testItSetDataParsleyConstraint(): void |
|
330 | - { |
|
331 | - $render = $this->getMock('foo', TextType::class, [ |
|
332 | - 'Constraints' => json_encode([ |
|
333 | - 'data-parsley-validator-foo' => '#bar', |
|
334 | - ]), |
|
335 | - ])->render(); |
|
336 | - |
|
337 | - $this->assertEquals(<<<'T' |
|
338 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-validator-foo="#bar" class="form-control" /></div> |
|
339 | -T, $render); |
|
340 | - } |
|
341 | - |
|
342 | - public function testItSetHelp(): void |
|
343 | - { |
|
344 | - $render = $this->getMock('foo', TextType::class, [ |
|
345 | - 'Help' => 'A help block', |
|
346 | - ])->render(); |
|
347 | - |
|
348 | - $this->assertEquals(<<<'T' |
|
349 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted">A help block</small></div> |
|
350 | -T, $render); |
|
351 | - } |
|
352 | - |
|
353 | - public function testItSetHelpAttr(): void |
|
354 | - { |
|
355 | - $render = $this->getMock('foo', TextType::class, [ |
|
356 | - 'Help' => 'A help block', |
|
357 | - 'help_attr' => [ |
|
358 | - 'class' => 'help-class', |
|
359 | - ], |
|
360 | - ])->render(); |
|
361 | - |
|
362 | - $this->assertEquals(<<<'T' |
|
363 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="help-class form-text text-muted">A help block</small></div> |
|
364 | -T, $render); |
|
365 | - } |
|
366 | - |
|
367 | - public function testItSetHelpHtml(): void |
|
368 | - { |
|
369 | - $render = $this->getMock('foo', TextType::class, [ |
|
370 | - 'Help' => '<a href="link">A help block</a>', |
|
371 | - 'help_html' => true, |
|
372 | - ])->render(); |
|
373 | - |
|
374 | - $this->assertEquals(<<<'T' |
|
375 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted"><a href="link">A help block</a></small></div> |
|
376 | -T, $render); |
|
377 | - } |
|
378 | - |
|
379 | - public function testItSetAttrExtra(): void |
|
380 | - { |
|
381 | - $render = $this->getMock('foo', TextType::class, [ |
|
382 | - 'attr' => [ |
|
383 | - 'class' => 'input-class', |
|
384 | - ], |
|
385 | - ])->render(); |
|
386 | - |
|
387 | - $this->assertEquals(<<<'T' |
|
388 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" /></div> |
|
389 | -T, $render); |
|
390 | - } |
|
391 | - |
|
392 | - public function testItSetAttrExtraWithEmptyData(): void |
|
393 | - { |
|
394 | - $render = $this->getMock('foo', TextType::class, [ |
|
395 | - 'attr' => [ |
|
396 | - 'class' => 'input-class', |
|
397 | - ], |
|
398 | - 'empty_data' => 'default', |
|
399 | - ])->render(); |
|
400 | - |
|
401 | - $this->assertEquals(<<<'T' |
|
402 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" placeholder="default" /></div> |
|
403 | -T, $render); |
|
404 | - } |
|
405 | - |
|
406 | - public function testItSetEmptyDataWithAttrExtra(): void |
|
407 | - { |
|
408 | - $render = $this->getMock('foo', TextType::class, [ |
|
409 | - 'empty_data' => 'default', |
|
410 | - 'attr' => [ |
|
411 | - 'class' => 'input-class', |
|
412 | - ], |
|
413 | - ])->render(); |
|
414 | - |
|
415 | - $this->assertEquals(<<<'T' |
|
416 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="input-class form-control" /></div> |
|
417 | -T, $render); |
|
418 | - } |
|
419 | - |
|
420 | - public function testItSetDisabled(): void |
|
421 | - { |
|
422 | - $render = $this->getMock('foo', TextType::class, [ |
|
423 | - 'disabled' => true, |
|
424 | - ])->render(); |
|
425 | - |
|
426 | - $this->assertEquals(<<<'T' |
|
427 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" disabled="disabled" class="form-control" /></div> |
|
428 | -T, $render); |
|
429 | - } |
|
430 | - |
|
431 | - public function testItSetEmptyData(): void |
|
432 | - { |
|
433 | - $render = $this->getMock('foo', TextType::class, [ |
|
434 | - 'empty_data' => 'default', |
|
435 | - ])->render(); |
|
436 | - |
|
437 | - $this->assertEquals(<<<'T' |
|
438 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="form-control" /></div> |
|
439 | -T, $render); |
|
440 | - } |
|
441 | - |
|
442 | - public function testItSetRowAttr(): void |
|
443 | - { |
|
444 | - $this->markTestSkipped('Not works...'); |
|
445 | - |
|
446 | - $render = $this->getMock('foo', TextType::class, [ |
|
447 | - 'row_attr' => [ |
|
448 | - 'class' => 'row-class', |
|
449 | - ], |
|
450 | - ])->render(); |
|
451 | - |
|
452 | - $this->assertEquals(<<<'T' |
|
453 | -<div class="row-class form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
454 | -T, $render); |
|
455 | - } |
|
456 | - |
|
457 | - public function getDefaultWithSpacesOptions(): array |
|
458 | - { |
|
459 | - return [ |
|
460 | - ['foo bar'], |
|
461 | - ['foo bar'], |
|
462 | - [' foo bar '], |
|
463 | - [' foo bar'], |
|
464 | - ['foo bar '], |
|
465 | - [' foo bar '], |
|
466 | - ]; |
|
467 | - } |
|
468 | - |
|
469 | - public function getRequiredOptions(): array |
|
470 | - { |
|
471 | - return [ |
|
472 | - [\json_encode(['required'])], |
|
473 | - [\json_encode(['required' => true])], |
|
474 | - [\json_encode(['required' => 'true'])], |
|
475 | - [\json_encode(['required' => 'required'])], |
|
476 | - ['required'], |
|
477 | - ]; |
|
478 | - } |
|
479 | -} |
@@ -31,449 +31,3 @@ |
||
31 | 31 | $render = $this->getMock('foo', TextType::class, [])->render(); |
32 | 32 | |
33 | 33 | $this->assertEquals(<<<'T' |
34 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
35 | -T, $render); |
|
36 | - } |
|
37 | - |
|
38 | - public function testItDefaultSlug(): void |
|
39 | - { |
|
40 | - $render = $this->getMock('foo_bar', TextType::class, [])->render(); |
|
41 | - |
|
42 | - $this->assertEquals(<<<'T' |
|
43 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
44 | -T, $render); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @dataProvider getDefaultWithSpacesOptions |
|
49 | - */ |
|
50 | - public function testItDefaultSpace($name): void |
|
51 | - { |
|
52 | - $render = $this->getMock($name, TextType::class, [])->render(); |
|
53 | - |
|
54 | - $this->assertEquals(<<<'T' |
|
55 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
56 | -T, $render); |
|
57 | - } |
|
58 | - |
|
59 | - public function testItSetLabel(): void |
|
60 | - { |
|
61 | - $render = $this->getMock('foo', TextType::class, [ |
|
62 | - 'Label' => 'My Label', |
|
63 | - ])->render(); |
|
64 | - |
|
65 | - $this->assertEquals(<<<'T' |
|
66 | -<div class="form-group"><label for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
67 | -T, $render); |
|
68 | - } |
|
69 | - |
|
70 | - public function testItSetLabelAttr(): void |
|
71 | - { |
|
72 | - $render = $this->getMock('foo', TextType::class, [ |
|
73 | - 'Label' => 'My Label', |
|
74 | - 'label_attr' => [ |
|
75 | - 'class' => 'label-class', |
|
76 | - ], |
|
77 | - ])->render(); |
|
78 | - |
|
79 | - $this->assertEquals(<<<'T' |
|
80 | -<div class="form-group"><label class="label-class" for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
81 | -T, $render); |
|
82 | - } |
|
83 | - |
|
84 | - public function testItSetDefault(): void |
|
85 | - { |
|
86 | - $render = $this->getMock('foo', TextType::class, [ |
|
87 | - 'Default' => 'fuz', |
|
88 | - ])->render(); |
|
89 | - |
|
90 | - $this->assertEquals(<<<'T' |
|
91 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" value="fuz" /></div> |
|
92 | -T, $render); |
|
93 | - } |
|
94 | - |
|
95 | - public function testItSetType(): void |
|
96 | - { |
|
97 | - $render = $this->getMock('foo', TextType::class, [ |
|
98 | - 'Type' => 'email', |
|
99 | - ])->render(); |
|
100 | - |
|
101 | - $this->assertEquals(<<<'T' |
|
102 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
103 | -T, $render); |
|
104 | - } |
|
105 | - |
|
106 | - public function testItSetRequired(): void |
|
107 | - { |
|
108 | - $render = $this->getMock('foo', TextType::class, [ |
|
109 | - 'required' => true, |
|
110 | - ])->render(); |
|
111 | - |
|
112 | - $this->assertEquals(<<<'T' |
|
113 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
114 | -T, $render); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @dataProvider getRequiredOptions |
|
119 | - * |
|
120 | - * @param string|array $required |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function testItSetRequiredConstraint($required): void |
|
124 | - { |
|
125 | - $render = $this->getMock('foo', TextType::class, [ |
|
126 | - 'Constraints' => $required, |
|
127 | - ])->render(); |
|
128 | - |
|
129 | - $this->assertEquals(<<<'T' |
|
130 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
131 | -T, $render); |
|
132 | - } |
|
133 | - |
|
134 | - public function testItSetTypeConstraint(): void |
|
135 | - { |
|
136 | - $render = $this->getMock('foo', TextType::class, [ |
|
137 | - 'Constraints' => json_encode([ |
|
138 | - 'type' => 'email', |
|
139 | - ]), |
|
140 | - ])->render(); |
|
141 | - |
|
142 | - $this->assertEquals(<<<'T' |
|
143 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
144 | -T, $render); |
|
145 | - } |
|
146 | - |
|
147 | - public function testItSetTypeAttrConstraint(): void |
|
148 | - { |
|
149 | - $render = $this->getMock('foo', TextType::class, [ |
|
150 | - 'attr' => [ |
|
151 | - 'type' => 'email', |
|
152 | - ], |
|
153 | - ])->render(); |
|
154 | - |
|
155 | - $this->assertEquals(<<<'T' |
|
156 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
157 | -T, $render); |
|
158 | - } |
|
159 | - |
|
160 | - public function testItSetDigitsConstraint(): void |
|
161 | - { |
|
162 | - $render = $this->getMock('foo', TextType::class, [ |
|
163 | - 'Constraints' => json_encode([ |
|
164 | - 'type' => 'digits', |
|
165 | - ]), |
|
166 | - ])->render(); |
|
167 | - |
|
168 | - $this->assertEquals(<<<'T' |
|
169 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="digits" class="form-control" /></div> |
|
170 | -T, $render); |
|
171 | - } |
|
172 | - |
|
173 | - public function testItSetAlphanumConstraint(): void |
|
174 | - { |
|
175 | - $render = $this->getMock('foo', TextType::class, [ |
|
176 | - 'Constraints' => json_encode([ |
|
177 | - 'Type' => 'Alphanum', |
|
178 | - ]), |
|
179 | - ])->render(); |
|
180 | - |
|
181 | - $this->assertEquals(<<<'T' |
|
182 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="alphanum" class="form-control" /></div> |
|
183 | -T, $render); |
|
184 | - } |
|
185 | - |
|
186 | - public function testItSetMinLengthConstraint(): void |
|
187 | - { |
|
188 | - $render = $this->getMock('foo', TextType::class, [ |
|
189 | - 'Constraints' => json_encode([ |
|
190 | - 'minlength' => 5, |
|
191 | - ]), |
|
192 | - ])->render(); |
|
193 | - |
|
194 | - $this->assertEquals(<<<'T' |
|
195 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" minlength="5" class="form-control" /></div> |
|
196 | -T, $render); |
|
197 | - } |
|
198 | - |
|
199 | - public function testItSetMaxLengthConstraint(): void |
|
200 | - { |
|
201 | - $render = $this->getMock('foo', TextType::class, [ |
|
202 | - 'Constraints' => json_encode([ |
|
203 | - 'maxlength' => 666, |
|
204 | - ]), |
|
205 | - ])->render(); |
|
206 | - |
|
207 | - $this->assertEquals(<<<'T' |
|
208 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" maxlength="666" class="form-control" /></div> |
|
209 | -T, $render); |
|
210 | - } |
|
211 | - |
|
212 | - public function testItSetLengthConstraint(): void |
|
213 | - { |
|
214 | - $render = $this->getMock('foo', TextType::class, [ |
|
215 | - 'Constraints' => json_encode([ |
|
216 | - 'length' => '[6,10]', |
|
217 | - ]), |
|
218 | - ])->render(); |
|
219 | - |
|
220 | - $this->assertEquals(<<<'T' |
|
221 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-length="[6,10]" class="form-control" /></div> |
|
222 | -T, $render); |
|
223 | - } |
|
224 | - |
|
225 | - public function testItSetMinConstraint(): void |
|
226 | - { |
|
227 | - $render = $this->getMock('foo', TextType::class, [ |
|
228 | - 'Constraints' => json_encode([ |
|
229 | - 'min' => 3, |
|
230 | - ]), |
|
231 | - ])->render(); |
|
232 | - |
|
233 | - $this->assertEquals(<<<'T' |
|
234 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" min="3" class="form-control" /></div> |
|
235 | -T, $render); |
|
236 | - } |
|
237 | - |
|
238 | - public function testItSetMaxConstraint(): void |
|
239 | - { |
|
240 | - $render = $this->getMock('foo', TextType::class, [ |
|
241 | - 'Constraints' => json_encode([ |
|
242 | - 'max' => 99, |
|
243 | - ]), |
|
244 | - ])->render(); |
|
245 | - |
|
246 | - $this->assertEquals(<<<'T' |
|
247 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" max="99" class="form-control" /></div> |
|
248 | -T, $render); |
|
249 | - } |
|
250 | - |
|
251 | - public function testItSetRangeConstraint(): void |
|
252 | - { |
|
253 | - $render = $this->getMock('foo', TextType::class, [ |
|
254 | - 'Constraints' => json_encode([ |
|
255 | - 'range' => '6,10', |
|
256 | - ]), |
|
257 | - ])->render(); |
|
258 | - |
|
259 | - $this->assertEquals(<<<'T' |
|
260 | -<div class="form-group"><label for="form_foo">Foo</label> <input type="range" id="form_foo" name="form[foo]" min="6" max="10" class="form-control" /></div> |
|
261 | -T, $render); |
|
262 | - } |
|
263 | - |
|
264 | - public function testItSetPatternConstraint(): void |
|
265 | - { |
|
266 | - $render = $this->getMock('foo', TextType::class, [ |
|
267 | - 'Constraints' => json_encode([ |
|
268 | - 'pattern' => "\+d", |
|
269 | - ]), |
|
270 | - ])->render(); |
|
271 | - |
|
272 | - $this->assertEquals(<<<'T' |
|
273 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" pattern="\+d" class="form-control" /></div> |
|
274 | -T, $render); |
|
275 | - } |
|
276 | - |
|
277 | - public function testItSetMinCheckConstraint(): void |
|
278 | - { |
|
279 | - $render = $this->getMock('foo', TextType::class, [ |
|
280 | - 'Constraints' => json_encode([ |
|
281 | - 'mincheck' => '3', |
|
282 | - ]), |
|
283 | - ])->render(); |
|
284 | - |
|
285 | - $this->assertEquals(<<<'T' |
|
286 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-mincheck="3" class="form-control" /></div> |
|
287 | -T, $render); |
|
288 | - } |
|
289 | - |
|
290 | - public function testItSetMaxCheckConstraint(): void |
|
291 | - { |
|
292 | - $render = $this->getMock('foo', TextType::class, [ |
|
293 | - 'Constraints' => json_encode([ |
|
294 | - 'maxcheck' => 5, |
|
295 | - ]), |
|
296 | - ])->render(); |
|
297 | - |
|
298 | - $this->assertEquals(<<<'T' |
|
299 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-maxcheck="5" class="form-control" /></div> |
|
300 | -T, $render); |
|
301 | - } |
|
302 | - |
|
303 | - public function testItSetCheckConstraint(): void |
|
304 | - { |
|
305 | - $render = $this->getMock('foo', TextType::class, [ |
|
306 | - 'Constraints' => json_encode([ |
|
307 | - 'check' => '[1,3]', |
|
308 | - ]), |
|
309 | - ])->render(); |
|
310 | - |
|
311 | - $this->assertEquals(<<<'T' |
|
312 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-check="[1,3]" class="form-control" /></div> |
|
313 | -T, $render); |
|
314 | - } |
|
315 | - |
|
316 | - public function testItSetEqualToConstraint(): void |
|
317 | - { |
|
318 | - $render = $this->getMock('foo', TextType::class, [ |
|
319 | - 'Constraints' => json_encode([ |
|
320 | - 'equalto' => '#another', |
|
321 | - ]), |
|
322 | - ])->render(); |
|
323 | - |
|
324 | - $this->assertEquals(<<<'T' |
|
325 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-equalto="#another" class="form-control" /></div> |
|
326 | -T, $render); |
|
327 | - } |
|
328 | - |
|
329 | - public function testItSetDataParsleyConstraint(): void |
|
330 | - { |
|
331 | - $render = $this->getMock('foo', TextType::class, [ |
|
332 | - 'Constraints' => json_encode([ |
|
333 | - 'data-parsley-validator-foo' => '#bar', |
|
334 | - ]), |
|
335 | - ])->render(); |
|
336 | - |
|
337 | - $this->assertEquals(<<<'T' |
|
338 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-validator-foo="#bar" class="form-control" /></div> |
|
339 | -T, $render); |
|
340 | - } |
|
341 | - |
|
342 | - public function testItSetHelp(): void |
|
343 | - { |
|
344 | - $render = $this->getMock('foo', TextType::class, [ |
|
345 | - 'Help' => 'A help block', |
|
346 | - ])->render(); |
|
347 | - |
|
348 | - $this->assertEquals(<<<'T' |
|
349 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted">A help block</small></div> |
|
350 | -T, $render); |
|
351 | - } |
|
352 | - |
|
353 | - public function testItSetHelpAttr(): void |
|
354 | - { |
|
355 | - $render = $this->getMock('foo', TextType::class, [ |
|
356 | - 'Help' => 'A help block', |
|
357 | - 'help_attr' => [ |
|
358 | - 'class' => 'help-class', |
|
359 | - ], |
|
360 | - ])->render(); |
|
361 | - |
|
362 | - $this->assertEquals(<<<'T' |
|
363 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="help-class form-text text-muted">A help block</small></div> |
|
364 | -T, $render); |
|
365 | - } |
|
366 | - |
|
367 | - public function testItSetHelpHtml(): void |
|
368 | - { |
|
369 | - $render = $this->getMock('foo', TextType::class, [ |
|
370 | - 'Help' => '<a href="link">A help block</a>', |
|
371 | - 'help_html' => true, |
|
372 | - ])->render(); |
|
373 | - |
|
374 | - $this->assertEquals(<<<'T' |
|
375 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted"><a href="link">A help block</a></small></div> |
|
376 | -T, $render); |
|
377 | - } |
|
378 | - |
|
379 | - public function testItSetAttrExtra(): void |
|
380 | - { |
|
381 | - $render = $this->getMock('foo', TextType::class, [ |
|
382 | - 'attr' => [ |
|
383 | - 'class' => 'input-class', |
|
384 | - ], |
|
385 | - ])->render(); |
|
386 | - |
|
387 | - $this->assertEquals(<<<'T' |
|
388 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" /></div> |
|
389 | -T, $render); |
|
390 | - } |
|
391 | - |
|
392 | - public function testItSetAttrExtraWithEmptyData(): void |
|
393 | - { |
|
394 | - $render = $this->getMock('foo', TextType::class, [ |
|
395 | - 'attr' => [ |
|
396 | - 'class' => 'input-class', |
|
397 | - ], |
|
398 | - 'empty_data' => 'default', |
|
399 | - ])->render(); |
|
400 | - |
|
401 | - $this->assertEquals(<<<'T' |
|
402 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" placeholder="default" /></div> |
|
403 | -T, $render); |
|
404 | - } |
|
405 | - |
|
406 | - public function testItSetEmptyDataWithAttrExtra(): void |
|
407 | - { |
|
408 | - $render = $this->getMock('foo', TextType::class, [ |
|
409 | - 'empty_data' => 'default', |
|
410 | - 'attr' => [ |
|
411 | - 'class' => 'input-class', |
|
412 | - ], |
|
413 | - ])->render(); |
|
414 | - |
|
415 | - $this->assertEquals(<<<'T' |
|
416 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="input-class form-control" /></div> |
|
417 | -T, $render); |
|
418 | - } |
|
419 | - |
|
420 | - public function testItSetDisabled(): void |
|
421 | - { |
|
422 | - $render = $this->getMock('foo', TextType::class, [ |
|
423 | - 'disabled' => true, |
|
424 | - ])->render(); |
|
425 | - |
|
426 | - $this->assertEquals(<<<'T' |
|
427 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" disabled="disabled" class="form-control" /></div> |
|
428 | -T, $render); |
|
429 | - } |
|
430 | - |
|
431 | - public function testItSetEmptyData(): void |
|
432 | - { |
|
433 | - $render = $this->getMock('foo', TextType::class, [ |
|
434 | - 'empty_data' => 'default', |
|
435 | - ])->render(); |
|
436 | - |
|
437 | - $this->assertEquals(<<<'T' |
|
438 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="form-control" /></div> |
|
439 | -T, $render); |
|
440 | - } |
|
441 | - |
|
442 | - public function testItSetRowAttr(): void |
|
443 | - { |
|
444 | - $this->markTestSkipped('Not works...'); |
|
445 | - |
|
446 | - $render = $this->getMock('foo', TextType::class, [ |
|
447 | - 'row_attr' => [ |
|
448 | - 'class' => 'row-class', |
|
449 | - ], |
|
450 | - ])->render(); |
|
451 | - |
|
452 | - $this->assertEquals(<<<'T' |
|
453 | -<div class="row-class form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
454 | -T, $render); |
|
455 | - } |
|
456 | - |
|
457 | - public function getDefaultWithSpacesOptions(): array |
|
458 | - { |
|
459 | - return [ |
|
460 | - ['foo bar'], |
|
461 | - ['foo bar'], |
|
462 | - [' foo bar '], |
|
463 | - [' foo bar'], |
|
464 | - ['foo bar '], |
|
465 | - [' foo bar '], |
|
466 | - ]; |
|
467 | - } |
|
468 | - |
|
469 | - public function getRequiredOptions(): array |
|
470 | - { |
|
471 | - return [ |
|
472 | - [\json_encode(['required'])], |
|
473 | - [\json_encode(['required' => true])], |
|
474 | - [\json_encode(['required' => 'true'])], |
|
475 | - [\json_encode(['required' => 'required'])], |
|
476 | - ['required'], |
|
477 | - ]; |
|
478 | - } |
|
479 | -} |
@@ -31,449 +31,3 @@ |
||
31 | 31 | $render = $this->getMock('foo', TextType::class, [])->render(); |
32 | 32 | |
33 | 33 | $this->assertEquals(<<<'T' |
34 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
35 | -T, $render); |
|
36 | - } |
|
37 | - |
|
38 | - public function testItDefaultSlug(): void |
|
39 | - { |
|
40 | - $render = $this->getMock('foo_bar', TextType::class, [])->render(); |
|
41 | - |
|
42 | - $this->assertEquals(<<<'T' |
|
43 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
44 | -T, $render); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @dataProvider getDefaultWithSpacesOptions |
|
49 | - */ |
|
50 | - public function testItDefaultSpace($name): void |
|
51 | - { |
|
52 | - $render = $this->getMock($name, TextType::class, [])->render(); |
|
53 | - |
|
54 | - $this->assertEquals(<<<'T' |
|
55 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
56 | -T, $render); |
|
57 | - } |
|
58 | - |
|
59 | - public function testItSetLabel(): void |
|
60 | - { |
|
61 | - $render = $this->getMock('foo', TextType::class, [ |
|
62 | - 'Label' => 'My Label', |
|
63 | - ])->render(); |
|
64 | - |
|
65 | - $this->assertEquals(<<<'T' |
|
66 | -<div class="form-group"><label for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
67 | -T, $render); |
|
68 | - } |
|
69 | - |
|
70 | - public function testItSetLabelAttr(): void |
|
71 | - { |
|
72 | - $render = $this->getMock('foo', TextType::class, [ |
|
73 | - 'Label' => 'My Label', |
|
74 | - 'label_attr' => [ |
|
75 | - 'class' => 'label-class', |
|
76 | - ], |
|
77 | - ])->render(); |
|
78 | - |
|
79 | - $this->assertEquals(<<<'T' |
|
80 | -<div class="form-group"><label class="label-class" for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
81 | -T, $render); |
|
82 | - } |
|
83 | - |
|
84 | - public function testItSetDefault(): void |
|
85 | - { |
|
86 | - $render = $this->getMock('foo', TextType::class, [ |
|
87 | - 'Default' => 'fuz', |
|
88 | - ])->render(); |
|
89 | - |
|
90 | - $this->assertEquals(<<<'T' |
|
91 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" value="fuz" /></div> |
|
92 | -T, $render); |
|
93 | - } |
|
94 | - |
|
95 | - public function testItSetType(): void |
|
96 | - { |
|
97 | - $render = $this->getMock('foo', TextType::class, [ |
|
98 | - 'Type' => 'email', |
|
99 | - ])->render(); |
|
100 | - |
|
101 | - $this->assertEquals(<<<'T' |
|
102 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
103 | -T, $render); |
|
104 | - } |
|
105 | - |
|
106 | - public function testItSetRequired(): void |
|
107 | - { |
|
108 | - $render = $this->getMock('foo', TextType::class, [ |
|
109 | - 'required' => true, |
|
110 | - ])->render(); |
|
111 | - |
|
112 | - $this->assertEquals(<<<'T' |
|
113 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
114 | -T, $render); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @dataProvider getRequiredOptions |
|
119 | - * |
|
120 | - * @param string|array $required |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function testItSetRequiredConstraint($required): void |
|
124 | - { |
|
125 | - $render = $this->getMock('foo', TextType::class, [ |
|
126 | - 'Constraints' => $required, |
|
127 | - ])->render(); |
|
128 | - |
|
129 | - $this->assertEquals(<<<'T' |
|
130 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
131 | -T, $render); |
|
132 | - } |
|
133 | - |
|
134 | - public function testItSetTypeConstraint(): void |
|
135 | - { |
|
136 | - $render = $this->getMock('foo', TextType::class, [ |
|
137 | - 'Constraints' => json_encode([ |
|
138 | - 'type' => 'email', |
|
139 | - ]), |
|
140 | - ])->render(); |
|
141 | - |
|
142 | - $this->assertEquals(<<<'T' |
|
143 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
144 | -T, $render); |
|
145 | - } |
|
146 | - |
|
147 | - public function testItSetTypeAttrConstraint(): void |
|
148 | - { |
|
149 | - $render = $this->getMock('foo', TextType::class, [ |
|
150 | - 'attr' => [ |
|
151 | - 'type' => 'email', |
|
152 | - ], |
|
153 | - ])->render(); |
|
154 | - |
|
155 | - $this->assertEquals(<<<'T' |
|
156 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
157 | -T, $render); |
|
158 | - } |
|
159 | - |
|
160 | - public function testItSetDigitsConstraint(): void |
|
161 | - { |
|
162 | - $render = $this->getMock('foo', TextType::class, [ |
|
163 | - 'Constraints' => json_encode([ |
|
164 | - 'type' => 'digits', |
|
165 | - ]), |
|
166 | - ])->render(); |
|
167 | - |
|
168 | - $this->assertEquals(<<<'T' |
|
169 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="digits" class="form-control" /></div> |
|
170 | -T, $render); |
|
171 | - } |
|
172 | - |
|
173 | - public function testItSetAlphanumConstraint(): void |
|
174 | - { |
|
175 | - $render = $this->getMock('foo', TextType::class, [ |
|
176 | - 'Constraints' => json_encode([ |
|
177 | - 'Type' => 'Alphanum', |
|
178 | - ]), |
|
179 | - ])->render(); |
|
180 | - |
|
181 | - $this->assertEquals(<<<'T' |
|
182 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="alphanum" class="form-control" /></div> |
|
183 | -T, $render); |
|
184 | - } |
|
185 | - |
|
186 | - public function testItSetMinLengthConstraint(): void |
|
187 | - { |
|
188 | - $render = $this->getMock('foo', TextType::class, [ |
|
189 | - 'Constraints' => json_encode([ |
|
190 | - 'minlength' => 5, |
|
191 | - ]), |
|
192 | - ])->render(); |
|
193 | - |
|
194 | - $this->assertEquals(<<<'T' |
|
195 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" minlength="5" class="form-control" /></div> |
|
196 | -T, $render); |
|
197 | - } |
|
198 | - |
|
199 | - public function testItSetMaxLengthConstraint(): void |
|
200 | - { |
|
201 | - $render = $this->getMock('foo', TextType::class, [ |
|
202 | - 'Constraints' => json_encode([ |
|
203 | - 'maxlength' => 666, |
|
204 | - ]), |
|
205 | - ])->render(); |
|
206 | - |
|
207 | - $this->assertEquals(<<<'T' |
|
208 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" maxlength="666" class="form-control" /></div> |
|
209 | -T, $render); |
|
210 | - } |
|
211 | - |
|
212 | - public function testItSetLengthConstraint(): void |
|
213 | - { |
|
214 | - $render = $this->getMock('foo', TextType::class, [ |
|
215 | - 'Constraints' => json_encode([ |
|
216 | - 'length' => '[6,10]', |
|
217 | - ]), |
|
218 | - ])->render(); |
|
219 | - |
|
220 | - $this->assertEquals(<<<'T' |
|
221 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-length="[6,10]" class="form-control" /></div> |
|
222 | -T, $render); |
|
223 | - } |
|
224 | - |
|
225 | - public function testItSetMinConstraint(): void |
|
226 | - { |
|
227 | - $render = $this->getMock('foo', TextType::class, [ |
|
228 | - 'Constraints' => json_encode([ |
|
229 | - 'min' => 3, |
|
230 | - ]), |
|
231 | - ])->render(); |
|
232 | - |
|
233 | - $this->assertEquals(<<<'T' |
|
234 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" min="3" class="form-control" /></div> |
|
235 | -T, $render); |
|
236 | - } |
|
237 | - |
|
238 | - public function testItSetMaxConstraint(): void |
|
239 | - { |
|
240 | - $render = $this->getMock('foo', TextType::class, [ |
|
241 | - 'Constraints' => json_encode([ |
|
242 | - 'max' => 99, |
|
243 | - ]), |
|
244 | - ])->render(); |
|
245 | - |
|
246 | - $this->assertEquals(<<<'T' |
|
247 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" max="99" class="form-control" /></div> |
|
248 | -T, $render); |
|
249 | - } |
|
250 | - |
|
251 | - public function testItSetRangeConstraint(): void |
|
252 | - { |
|
253 | - $render = $this->getMock('foo', TextType::class, [ |
|
254 | - 'Constraints' => json_encode([ |
|
255 | - 'range' => '6,10', |
|
256 | - ]), |
|
257 | - ])->render(); |
|
258 | - |
|
259 | - $this->assertEquals(<<<'T' |
|
260 | -<div class="form-group"><label for="form_foo">Foo</label> <input type="range" id="form_foo" name="form[foo]" min="6" max="10" class="form-control" /></div> |
|
261 | -T, $render); |
|
262 | - } |
|
263 | - |
|
264 | - public function testItSetPatternConstraint(): void |
|
265 | - { |
|
266 | - $render = $this->getMock('foo', TextType::class, [ |
|
267 | - 'Constraints' => json_encode([ |
|
268 | - 'pattern' => "\+d", |
|
269 | - ]), |
|
270 | - ])->render(); |
|
271 | - |
|
272 | - $this->assertEquals(<<<'T' |
|
273 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" pattern="\+d" class="form-control" /></div> |
|
274 | -T, $render); |
|
275 | - } |
|
276 | - |
|
277 | - public function testItSetMinCheckConstraint(): void |
|
278 | - { |
|
279 | - $render = $this->getMock('foo', TextType::class, [ |
|
280 | - 'Constraints' => json_encode([ |
|
281 | - 'mincheck' => '3', |
|
282 | - ]), |
|
283 | - ])->render(); |
|
284 | - |
|
285 | - $this->assertEquals(<<<'T' |
|
286 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-mincheck="3" class="form-control" /></div> |
|
287 | -T, $render); |
|
288 | - } |
|
289 | - |
|
290 | - public function testItSetMaxCheckConstraint(): void |
|
291 | - { |
|
292 | - $render = $this->getMock('foo', TextType::class, [ |
|
293 | - 'Constraints' => json_encode([ |
|
294 | - 'maxcheck' => 5, |
|
295 | - ]), |
|
296 | - ])->render(); |
|
297 | - |
|
298 | - $this->assertEquals(<<<'T' |
|
299 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-maxcheck="5" class="form-control" /></div> |
|
300 | -T, $render); |
|
301 | - } |
|
302 | - |
|
303 | - public function testItSetCheckConstraint(): void |
|
304 | - { |
|
305 | - $render = $this->getMock('foo', TextType::class, [ |
|
306 | - 'Constraints' => json_encode([ |
|
307 | - 'check' => '[1,3]', |
|
308 | - ]), |
|
309 | - ])->render(); |
|
310 | - |
|
311 | - $this->assertEquals(<<<'T' |
|
312 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-check="[1,3]" class="form-control" /></div> |
|
313 | -T, $render); |
|
314 | - } |
|
315 | - |
|
316 | - public function testItSetEqualToConstraint(): void |
|
317 | - { |
|
318 | - $render = $this->getMock('foo', TextType::class, [ |
|
319 | - 'Constraints' => json_encode([ |
|
320 | - 'equalto' => '#another', |
|
321 | - ]), |
|
322 | - ])->render(); |
|
323 | - |
|
324 | - $this->assertEquals(<<<'T' |
|
325 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-equalto="#another" class="form-control" /></div> |
|
326 | -T, $render); |
|
327 | - } |
|
328 | - |
|
329 | - public function testItSetDataParsleyConstraint(): void |
|
330 | - { |
|
331 | - $render = $this->getMock('foo', TextType::class, [ |
|
332 | - 'Constraints' => json_encode([ |
|
333 | - 'data-parsley-validator-foo' => '#bar', |
|
334 | - ]), |
|
335 | - ])->render(); |
|
336 | - |
|
337 | - $this->assertEquals(<<<'T' |
|
338 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-validator-foo="#bar" class="form-control" /></div> |
|
339 | -T, $render); |
|
340 | - } |
|
341 | - |
|
342 | - public function testItSetHelp(): void |
|
343 | - { |
|
344 | - $render = $this->getMock('foo', TextType::class, [ |
|
345 | - 'Help' => 'A help block', |
|
346 | - ])->render(); |
|
347 | - |
|
348 | - $this->assertEquals(<<<'T' |
|
349 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted">A help block</small></div> |
|
350 | -T, $render); |
|
351 | - } |
|
352 | - |
|
353 | - public function testItSetHelpAttr(): void |
|
354 | - { |
|
355 | - $render = $this->getMock('foo', TextType::class, [ |
|
356 | - 'Help' => 'A help block', |
|
357 | - 'help_attr' => [ |
|
358 | - 'class' => 'help-class', |
|
359 | - ], |
|
360 | - ])->render(); |
|
361 | - |
|
362 | - $this->assertEquals(<<<'T' |
|
363 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="help-class form-text text-muted">A help block</small></div> |
|
364 | -T, $render); |
|
365 | - } |
|
366 | - |
|
367 | - public function testItSetHelpHtml(): void |
|
368 | - { |
|
369 | - $render = $this->getMock('foo', TextType::class, [ |
|
370 | - 'Help' => '<a href="link">A help block</a>', |
|
371 | - 'help_html' => true, |
|
372 | - ])->render(); |
|
373 | - |
|
374 | - $this->assertEquals(<<<'T' |
|
375 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted"><a href="link">A help block</a></small></div> |
|
376 | -T, $render); |
|
377 | - } |
|
378 | - |
|
379 | - public function testItSetAttrExtra(): void |
|
380 | - { |
|
381 | - $render = $this->getMock('foo', TextType::class, [ |
|
382 | - 'attr' => [ |
|
383 | - 'class' => 'input-class', |
|
384 | - ], |
|
385 | - ])->render(); |
|
386 | - |
|
387 | - $this->assertEquals(<<<'T' |
|
388 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" /></div> |
|
389 | -T, $render); |
|
390 | - } |
|
391 | - |
|
392 | - public function testItSetAttrExtraWithEmptyData(): void |
|
393 | - { |
|
394 | - $render = $this->getMock('foo', TextType::class, [ |
|
395 | - 'attr' => [ |
|
396 | - 'class' => 'input-class', |
|
397 | - ], |
|
398 | - 'empty_data' => 'default', |
|
399 | - ])->render(); |
|
400 | - |
|
401 | - $this->assertEquals(<<<'T' |
|
402 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" placeholder="default" /></div> |
|
403 | -T, $render); |
|
404 | - } |
|
405 | - |
|
406 | - public function testItSetEmptyDataWithAttrExtra(): void |
|
407 | - { |
|
408 | - $render = $this->getMock('foo', TextType::class, [ |
|
409 | - 'empty_data' => 'default', |
|
410 | - 'attr' => [ |
|
411 | - 'class' => 'input-class', |
|
412 | - ], |
|
413 | - ])->render(); |
|
414 | - |
|
415 | - $this->assertEquals(<<<'T' |
|
416 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="input-class form-control" /></div> |
|
417 | -T, $render); |
|
418 | - } |
|
419 | - |
|
420 | - public function testItSetDisabled(): void |
|
421 | - { |
|
422 | - $render = $this->getMock('foo', TextType::class, [ |
|
423 | - 'disabled' => true, |
|
424 | - ])->render(); |
|
425 | - |
|
426 | - $this->assertEquals(<<<'T' |
|
427 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" disabled="disabled" class="form-control" /></div> |
|
428 | -T, $render); |
|
429 | - } |
|
430 | - |
|
431 | - public function testItSetEmptyData(): void |
|
432 | - { |
|
433 | - $render = $this->getMock('foo', TextType::class, [ |
|
434 | - 'empty_data' => 'default', |
|
435 | - ])->render(); |
|
436 | - |
|
437 | - $this->assertEquals(<<<'T' |
|
438 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="form-control" /></div> |
|
439 | -T, $render); |
|
440 | - } |
|
441 | - |
|
442 | - public function testItSetRowAttr(): void |
|
443 | - { |
|
444 | - $this->markTestSkipped('Not works...'); |
|
445 | - |
|
446 | - $render = $this->getMock('foo', TextType::class, [ |
|
447 | - 'row_attr' => [ |
|
448 | - 'class' => 'row-class', |
|
449 | - ], |
|
450 | - ])->render(); |
|
451 | - |
|
452 | - $this->assertEquals(<<<'T' |
|
453 | -<div class="row-class form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
454 | -T, $render); |
|
455 | - } |
|
456 | - |
|
457 | - public function getDefaultWithSpacesOptions(): array |
|
458 | - { |
|
459 | - return [ |
|
460 | - ['foo bar'], |
|
461 | - ['foo bar'], |
|
462 | - [' foo bar '], |
|
463 | - [' foo bar'], |
|
464 | - ['foo bar '], |
|
465 | - [' foo bar '], |
|
466 | - ]; |
|
467 | - } |
|
468 | - |
|
469 | - public function getRequiredOptions(): array |
|
470 | - { |
|
471 | - return [ |
|
472 | - [\json_encode(['required'])], |
|
473 | - [\json_encode(['required' => true])], |
|
474 | - [\json_encode(['required' => 'true'])], |
|
475 | - [\json_encode(['required' => 'required'])], |
|
476 | - ['required'], |
|
477 | - ]; |
|
478 | - } |
|
479 | -} |
@@ -31,449 +31,3 @@ |
||
31 | 31 | $render = $this->getMock('foo', TextType::class, [])->render(); |
32 | 32 | |
33 | 33 | $this->assertEquals(<<<'T' |
34 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
35 | -T, $render); |
|
36 | - } |
|
37 | - |
|
38 | - public function testItDefaultSlug(): void |
|
39 | - { |
|
40 | - $render = $this->getMock('foo_bar', TextType::class, [])->render(); |
|
41 | - |
|
42 | - $this->assertEquals(<<<'T' |
|
43 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
44 | -T, $render); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @dataProvider getDefaultWithSpacesOptions |
|
49 | - */ |
|
50 | - public function testItDefaultSpace($name): void |
|
51 | - { |
|
52 | - $render = $this->getMock($name, TextType::class, [])->render(); |
|
53 | - |
|
54 | - $this->assertEquals(<<<'T' |
|
55 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
56 | -T, $render); |
|
57 | - } |
|
58 | - |
|
59 | - public function testItSetLabel(): void |
|
60 | - { |
|
61 | - $render = $this->getMock('foo', TextType::class, [ |
|
62 | - 'Label' => 'My Label', |
|
63 | - ])->render(); |
|
64 | - |
|
65 | - $this->assertEquals(<<<'T' |
|
66 | -<div class="form-group"><label for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
67 | -T, $render); |
|
68 | - } |
|
69 | - |
|
70 | - public function testItSetLabelAttr(): void |
|
71 | - { |
|
72 | - $render = $this->getMock('foo', TextType::class, [ |
|
73 | - 'Label' => 'My Label', |
|
74 | - 'label_attr' => [ |
|
75 | - 'class' => 'label-class', |
|
76 | - ], |
|
77 | - ])->render(); |
|
78 | - |
|
79 | - $this->assertEquals(<<<'T' |
|
80 | -<div class="form-group"><label class="label-class" for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
81 | -T, $render); |
|
82 | - } |
|
83 | - |
|
84 | - public function testItSetDefault(): void |
|
85 | - { |
|
86 | - $render = $this->getMock('foo', TextType::class, [ |
|
87 | - 'Default' => 'fuz', |
|
88 | - ])->render(); |
|
89 | - |
|
90 | - $this->assertEquals(<<<'T' |
|
91 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" value="fuz" /></div> |
|
92 | -T, $render); |
|
93 | - } |
|
94 | - |
|
95 | - public function testItSetType(): void |
|
96 | - { |
|
97 | - $render = $this->getMock('foo', TextType::class, [ |
|
98 | - 'Type' => 'email', |
|
99 | - ])->render(); |
|
100 | - |
|
101 | - $this->assertEquals(<<<'T' |
|
102 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
103 | -T, $render); |
|
104 | - } |
|
105 | - |
|
106 | - public function testItSetRequired(): void |
|
107 | - { |
|
108 | - $render = $this->getMock('foo', TextType::class, [ |
|
109 | - 'required' => true, |
|
110 | - ])->render(); |
|
111 | - |
|
112 | - $this->assertEquals(<<<'T' |
|
113 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
114 | -T, $render); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @dataProvider getRequiredOptions |
|
119 | - * |
|
120 | - * @param string|array $required |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function testItSetRequiredConstraint($required): void |
|
124 | - { |
|
125 | - $render = $this->getMock('foo', TextType::class, [ |
|
126 | - 'Constraints' => $required, |
|
127 | - ])->render(); |
|
128 | - |
|
129 | - $this->assertEquals(<<<'T' |
|
130 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
131 | -T, $render); |
|
132 | - } |
|
133 | - |
|
134 | - public function testItSetTypeConstraint(): void |
|
135 | - { |
|
136 | - $render = $this->getMock('foo', TextType::class, [ |
|
137 | - 'Constraints' => json_encode([ |
|
138 | - 'type' => 'email', |
|
139 | - ]), |
|
140 | - ])->render(); |
|
141 | - |
|
142 | - $this->assertEquals(<<<'T' |
|
143 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
144 | -T, $render); |
|
145 | - } |
|
146 | - |
|
147 | - public function testItSetTypeAttrConstraint(): void |
|
148 | - { |
|
149 | - $render = $this->getMock('foo', TextType::class, [ |
|
150 | - 'attr' => [ |
|
151 | - 'type' => 'email', |
|
152 | - ], |
|
153 | - ])->render(); |
|
154 | - |
|
155 | - $this->assertEquals(<<<'T' |
|
156 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
157 | -T, $render); |
|
158 | - } |
|
159 | - |
|
160 | - public function testItSetDigitsConstraint(): void |
|
161 | - { |
|
162 | - $render = $this->getMock('foo', TextType::class, [ |
|
163 | - 'Constraints' => json_encode([ |
|
164 | - 'type' => 'digits', |
|
165 | - ]), |
|
166 | - ])->render(); |
|
167 | - |
|
168 | - $this->assertEquals(<<<'T' |
|
169 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="digits" class="form-control" /></div> |
|
170 | -T, $render); |
|
171 | - } |
|
172 | - |
|
173 | - public function testItSetAlphanumConstraint(): void |
|
174 | - { |
|
175 | - $render = $this->getMock('foo', TextType::class, [ |
|
176 | - 'Constraints' => json_encode([ |
|
177 | - 'Type' => 'Alphanum', |
|
178 | - ]), |
|
179 | - ])->render(); |
|
180 | - |
|
181 | - $this->assertEquals(<<<'T' |
|
182 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="alphanum" class="form-control" /></div> |
|
183 | -T, $render); |
|
184 | - } |
|
185 | - |
|
186 | - public function testItSetMinLengthConstraint(): void |
|
187 | - { |
|
188 | - $render = $this->getMock('foo', TextType::class, [ |
|
189 | - 'Constraints' => json_encode([ |
|
190 | - 'minlength' => 5, |
|
191 | - ]), |
|
192 | - ])->render(); |
|
193 | - |
|
194 | - $this->assertEquals(<<<'T' |
|
195 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" minlength="5" class="form-control" /></div> |
|
196 | -T, $render); |
|
197 | - } |
|
198 | - |
|
199 | - public function testItSetMaxLengthConstraint(): void |
|
200 | - { |
|
201 | - $render = $this->getMock('foo', TextType::class, [ |
|
202 | - 'Constraints' => json_encode([ |
|
203 | - 'maxlength' => 666, |
|
204 | - ]), |
|
205 | - ])->render(); |
|
206 | - |
|
207 | - $this->assertEquals(<<<'T' |
|
208 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" maxlength="666" class="form-control" /></div> |
|
209 | -T, $render); |
|
210 | - } |
|
211 | - |
|
212 | - public function testItSetLengthConstraint(): void |
|
213 | - { |
|
214 | - $render = $this->getMock('foo', TextType::class, [ |
|
215 | - 'Constraints' => json_encode([ |
|
216 | - 'length' => '[6,10]', |
|
217 | - ]), |
|
218 | - ])->render(); |
|
219 | - |
|
220 | - $this->assertEquals(<<<'T' |
|
221 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-length="[6,10]" class="form-control" /></div> |
|
222 | -T, $render); |
|
223 | - } |
|
224 | - |
|
225 | - public function testItSetMinConstraint(): void |
|
226 | - { |
|
227 | - $render = $this->getMock('foo', TextType::class, [ |
|
228 | - 'Constraints' => json_encode([ |
|
229 | - 'min' => 3, |
|
230 | - ]), |
|
231 | - ])->render(); |
|
232 | - |
|
233 | - $this->assertEquals(<<<'T' |
|
234 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" min="3" class="form-control" /></div> |
|
235 | -T, $render); |
|
236 | - } |
|
237 | - |
|
238 | - public function testItSetMaxConstraint(): void |
|
239 | - { |
|
240 | - $render = $this->getMock('foo', TextType::class, [ |
|
241 | - 'Constraints' => json_encode([ |
|
242 | - 'max' => 99, |
|
243 | - ]), |
|
244 | - ])->render(); |
|
245 | - |
|
246 | - $this->assertEquals(<<<'T' |
|
247 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" max="99" class="form-control" /></div> |
|
248 | -T, $render); |
|
249 | - } |
|
250 | - |
|
251 | - public function testItSetRangeConstraint(): void |
|
252 | - { |
|
253 | - $render = $this->getMock('foo', TextType::class, [ |
|
254 | - 'Constraints' => json_encode([ |
|
255 | - 'range' => '6,10', |
|
256 | - ]), |
|
257 | - ])->render(); |
|
258 | - |
|
259 | - $this->assertEquals(<<<'T' |
|
260 | -<div class="form-group"><label for="form_foo">Foo</label> <input type="range" id="form_foo" name="form[foo]" min="6" max="10" class="form-control" /></div> |
|
261 | -T, $render); |
|
262 | - } |
|
263 | - |
|
264 | - public function testItSetPatternConstraint(): void |
|
265 | - { |
|
266 | - $render = $this->getMock('foo', TextType::class, [ |
|
267 | - 'Constraints' => json_encode([ |
|
268 | - 'pattern' => "\+d", |
|
269 | - ]), |
|
270 | - ])->render(); |
|
271 | - |
|
272 | - $this->assertEquals(<<<'T' |
|
273 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" pattern="\+d" class="form-control" /></div> |
|
274 | -T, $render); |
|
275 | - } |
|
276 | - |
|
277 | - public function testItSetMinCheckConstraint(): void |
|
278 | - { |
|
279 | - $render = $this->getMock('foo', TextType::class, [ |
|
280 | - 'Constraints' => json_encode([ |
|
281 | - 'mincheck' => '3', |
|
282 | - ]), |
|
283 | - ])->render(); |
|
284 | - |
|
285 | - $this->assertEquals(<<<'T' |
|
286 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-mincheck="3" class="form-control" /></div> |
|
287 | -T, $render); |
|
288 | - } |
|
289 | - |
|
290 | - public function testItSetMaxCheckConstraint(): void |
|
291 | - { |
|
292 | - $render = $this->getMock('foo', TextType::class, [ |
|
293 | - 'Constraints' => json_encode([ |
|
294 | - 'maxcheck' => 5, |
|
295 | - ]), |
|
296 | - ])->render(); |
|
297 | - |
|
298 | - $this->assertEquals(<<<'T' |
|
299 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-maxcheck="5" class="form-control" /></div> |
|
300 | -T, $render); |
|
301 | - } |
|
302 | - |
|
303 | - public function testItSetCheckConstraint(): void |
|
304 | - { |
|
305 | - $render = $this->getMock('foo', TextType::class, [ |
|
306 | - 'Constraints' => json_encode([ |
|
307 | - 'check' => '[1,3]', |
|
308 | - ]), |
|
309 | - ])->render(); |
|
310 | - |
|
311 | - $this->assertEquals(<<<'T' |
|
312 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-check="[1,3]" class="form-control" /></div> |
|
313 | -T, $render); |
|
314 | - } |
|
315 | - |
|
316 | - public function testItSetEqualToConstraint(): void |
|
317 | - { |
|
318 | - $render = $this->getMock('foo', TextType::class, [ |
|
319 | - 'Constraints' => json_encode([ |
|
320 | - 'equalto' => '#another', |
|
321 | - ]), |
|
322 | - ])->render(); |
|
323 | - |
|
324 | - $this->assertEquals(<<<'T' |
|
325 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-equalto="#another" class="form-control" /></div> |
|
326 | -T, $render); |
|
327 | - } |
|
328 | - |
|
329 | - public function testItSetDataParsleyConstraint(): void |
|
330 | - { |
|
331 | - $render = $this->getMock('foo', TextType::class, [ |
|
332 | - 'Constraints' => json_encode([ |
|
333 | - 'data-parsley-validator-foo' => '#bar', |
|
334 | - ]), |
|
335 | - ])->render(); |
|
336 | - |
|
337 | - $this->assertEquals(<<<'T' |
|
338 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-validator-foo="#bar" class="form-control" /></div> |
|
339 | -T, $render); |
|
340 | - } |
|
341 | - |
|
342 | - public function testItSetHelp(): void |
|
343 | - { |
|
344 | - $render = $this->getMock('foo', TextType::class, [ |
|
345 | - 'Help' => 'A help block', |
|
346 | - ])->render(); |
|
347 | - |
|
348 | - $this->assertEquals(<<<'T' |
|
349 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted">A help block</small></div> |
|
350 | -T, $render); |
|
351 | - } |
|
352 | - |
|
353 | - public function testItSetHelpAttr(): void |
|
354 | - { |
|
355 | - $render = $this->getMock('foo', TextType::class, [ |
|
356 | - 'Help' => 'A help block', |
|
357 | - 'help_attr' => [ |
|
358 | - 'class' => 'help-class', |
|
359 | - ], |
|
360 | - ])->render(); |
|
361 | - |
|
362 | - $this->assertEquals(<<<'T' |
|
363 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="help-class form-text text-muted">A help block</small></div> |
|
364 | -T, $render); |
|
365 | - } |
|
366 | - |
|
367 | - public function testItSetHelpHtml(): void |
|
368 | - { |
|
369 | - $render = $this->getMock('foo', TextType::class, [ |
|
370 | - 'Help' => '<a href="link">A help block</a>', |
|
371 | - 'help_html' => true, |
|
372 | - ])->render(); |
|
373 | - |
|
374 | - $this->assertEquals(<<<'T' |
|
375 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted"><a href="link">A help block</a></small></div> |
|
376 | -T, $render); |
|
377 | - } |
|
378 | - |
|
379 | - public function testItSetAttrExtra(): void |
|
380 | - { |
|
381 | - $render = $this->getMock('foo', TextType::class, [ |
|
382 | - 'attr' => [ |
|
383 | - 'class' => 'input-class', |
|
384 | - ], |
|
385 | - ])->render(); |
|
386 | - |
|
387 | - $this->assertEquals(<<<'T' |
|
388 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" /></div> |
|
389 | -T, $render); |
|
390 | - } |
|
391 | - |
|
392 | - public function testItSetAttrExtraWithEmptyData(): void |
|
393 | - { |
|
394 | - $render = $this->getMock('foo', TextType::class, [ |
|
395 | - 'attr' => [ |
|
396 | - 'class' => 'input-class', |
|
397 | - ], |
|
398 | - 'empty_data' => 'default', |
|
399 | - ])->render(); |
|
400 | - |
|
401 | - $this->assertEquals(<<<'T' |
|
402 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" placeholder="default" /></div> |
|
403 | -T, $render); |
|
404 | - } |
|
405 | - |
|
406 | - public function testItSetEmptyDataWithAttrExtra(): void |
|
407 | - { |
|
408 | - $render = $this->getMock('foo', TextType::class, [ |
|
409 | - 'empty_data' => 'default', |
|
410 | - 'attr' => [ |
|
411 | - 'class' => 'input-class', |
|
412 | - ], |
|
413 | - ])->render(); |
|
414 | - |
|
415 | - $this->assertEquals(<<<'T' |
|
416 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="input-class form-control" /></div> |
|
417 | -T, $render); |
|
418 | - } |
|
419 | - |
|
420 | - public function testItSetDisabled(): void |
|
421 | - { |
|
422 | - $render = $this->getMock('foo', TextType::class, [ |
|
423 | - 'disabled' => true, |
|
424 | - ])->render(); |
|
425 | - |
|
426 | - $this->assertEquals(<<<'T' |
|
427 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" disabled="disabled" class="form-control" /></div> |
|
428 | -T, $render); |
|
429 | - } |
|
430 | - |
|
431 | - public function testItSetEmptyData(): void |
|
432 | - { |
|
433 | - $render = $this->getMock('foo', TextType::class, [ |
|
434 | - 'empty_data' => 'default', |
|
435 | - ])->render(); |
|
436 | - |
|
437 | - $this->assertEquals(<<<'T' |
|
438 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="form-control" /></div> |
|
439 | -T, $render); |
|
440 | - } |
|
441 | - |
|
442 | - public function testItSetRowAttr(): void |
|
443 | - { |
|
444 | - $this->markTestSkipped('Not works...'); |
|
445 | - |
|
446 | - $render = $this->getMock('foo', TextType::class, [ |
|
447 | - 'row_attr' => [ |
|
448 | - 'class' => 'row-class', |
|
449 | - ], |
|
450 | - ])->render(); |
|
451 | - |
|
452 | - $this->assertEquals(<<<'T' |
|
453 | -<div class="row-class form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
454 | -T, $render); |
|
455 | - } |
|
456 | - |
|
457 | - public function getDefaultWithSpacesOptions(): array |
|
458 | - { |
|
459 | - return [ |
|
460 | - ['foo bar'], |
|
461 | - ['foo bar'], |
|
462 | - [' foo bar '], |
|
463 | - [' foo bar'], |
|
464 | - ['foo bar '], |
|
465 | - [' foo bar '], |
|
466 | - ]; |
|
467 | - } |
|
468 | - |
|
469 | - public function getRequiredOptions(): array |
|
470 | - { |
|
471 | - return [ |
|
472 | - [\json_encode(['required'])], |
|
473 | - [\json_encode(['required' => true])], |
|
474 | - [\json_encode(['required' => 'true'])], |
|
475 | - [\json_encode(['required' => 'required'])], |
|
476 | - ['required'], |
|
477 | - ]; |
|
478 | - } |
|
479 | -} |
@@ -31,449 +31,3 @@ |
||
31 | 31 | $render = $this->getMock('foo', TextType::class, [])->render(); |
32 | 32 | |
33 | 33 | $this->assertEquals(<<<'T' |
34 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
35 | -T, $render); |
|
36 | - } |
|
37 | - |
|
38 | - public function testItDefaultSlug(): void |
|
39 | - { |
|
40 | - $render = $this->getMock('foo_bar', TextType::class, [])->render(); |
|
41 | - |
|
42 | - $this->assertEquals(<<<'T' |
|
43 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
44 | -T, $render); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * @dataProvider getDefaultWithSpacesOptions |
|
49 | - */ |
|
50 | - public function testItDefaultSpace($name): void |
|
51 | - { |
|
52 | - $render = $this->getMock($name, TextType::class, [])->render(); |
|
53 | - |
|
54 | - $this->assertEquals(<<<'T' |
|
55 | -<div class="form-group"><label for="form_foo_bar">Foo bar</label><input type="text" id="form_foo_bar" name="form[foo_bar]" class="form-control" /></div> |
|
56 | -T, $render); |
|
57 | - } |
|
58 | - |
|
59 | - public function testItSetLabel(): void |
|
60 | - { |
|
61 | - $render = $this->getMock('foo', TextType::class, [ |
|
62 | - 'Label' => 'My Label', |
|
63 | - ])->render(); |
|
64 | - |
|
65 | - $this->assertEquals(<<<'T' |
|
66 | -<div class="form-group"><label for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
67 | -T, $render); |
|
68 | - } |
|
69 | - |
|
70 | - public function testItSetLabelAttr(): void |
|
71 | - { |
|
72 | - $render = $this->getMock('foo', TextType::class, [ |
|
73 | - 'Label' => 'My Label', |
|
74 | - 'label_attr' => [ |
|
75 | - 'class' => 'label-class', |
|
76 | - ], |
|
77 | - ])->render(); |
|
78 | - |
|
79 | - $this->assertEquals(<<<'T' |
|
80 | -<div class="form-group"><label class="label-class" for="form_foo">My Label</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
81 | -T, $render); |
|
82 | - } |
|
83 | - |
|
84 | - public function testItSetDefault(): void |
|
85 | - { |
|
86 | - $render = $this->getMock('foo', TextType::class, [ |
|
87 | - 'Default' => 'fuz', |
|
88 | - ])->render(); |
|
89 | - |
|
90 | - $this->assertEquals(<<<'T' |
|
91 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" value="fuz" /></div> |
|
92 | -T, $render); |
|
93 | - } |
|
94 | - |
|
95 | - public function testItSetType(): void |
|
96 | - { |
|
97 | - $render = $this->getMock('foo', TextType::class, [ |
|
98 | - 'Type' => 'email', |
|
99 | - ])->render(); |
|
100 | - |
|
101 | - $this->assertEquals(<<<'T' |
|
102 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
103 | -T, $render); |
|
104 | - } |
|
105 | - |
|
106 | - public function testItSetRequired(): void |
|
107 | - { |
|
108 | - $render = $this->getMock('foo', TextType::class, [ |
|
109 | - 'required' => true, |
|
110 | - ])->render(); |
|
111 | - |
|
112 | - $this->assertEquals(<<<'T' |
|
113 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
114 | -T, $render); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @dataProvider getRequiredOptions |
|
119 | - * |
|
120 | - * @param string|array $required |
|
121 | - * @return void |
|
122 | - */ |
|
123 | - public function testItSetRequiredConstraint($required): void |
|
124 | - { |
|
125 | - $render = $this->getMock('foo', TextType::class, [ |
|
126 | - 'Constraints' => $required, |
|
127 | - ])->render(); |
|
128 | - |
|
129 | - $this->assertEquals(<<<'T' |
|
130 | -<div class="form-group"><label for="form_foo" class="required">Foo</label><input type="text" id="form_foo" name="form[foo]" required="required" class="form-control" /></div> |
|
131 | -T, $render); |
|
132 | - } |
|
133 | - |
|
134 | - public function testItSetTypeConstraint(): void |
|
135 | - { |
|
136 | - $render = $this->getMock('foo', TextType::class, [ |
|
137 | - 'Constraints' => json_encode([ |
|
138 | - 'type' => 'email', |
|
139 | - ]), |
|
140 | - ])->render(); |
|
141 | - |
|
142 | - $this->assertEquals(<<<'T' |
|
143 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
144 | -T, $render); |
|
145 | - } |
|
146 | - |
|
147 | - public function testItSetTypeAttrConstraint(): void |
|
148 | - { |
|
149 | - $render = $this->getMock('foo', TextType::class, [ |
|
150 | - 'attr' => [ |
|
151 | - 'type' => 'email', |
|
152 | - ], |
|
153 | - ])->render(); |
|
154 | - |
|
155 | - $this->assertEquals(<<<'T' |
|
156 | -<div class="form-group"><label for="form_foo">Foo</label><input type="email" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
157 | -T, $render); |
|
158 | - } |
|
159 | - |
|
160 | - public function testItSetDigitsConstraint(): void |
|
161 | - { |
|
162 | - $render = $this->getMock('foo', TextType::class, [ |
|
163 | - 'Constraints' => json_encode([ |
|
164 | - 'type' => 'digits', |
|
165 | - ]), |
|
166 | - ])->render(); |
|
167 | - |
|
168 | - $this->assertEquals(<<<'T' |
|
169 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="digits" class="form-control" /></div> |
|
170 | -T, $render); |
|
171 | - } |
|
172 | - |
|
173 | - public function testItSetAlphanumConstraint(): void |
|
174 | - { |
|
175 | - $render = $this->getMock('foo', TextType::class, [ |
|
176 | - 'Constraints' => json_encode([ |
|
177 | - 'Type' => 'Alphanum', |
|
178 | - ]), |
|
179 | - ])->render(); |
|
180 | - |
|
181 | - $this->assertEquals(<<<'T' |
|
182 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-type="alphanum" class="form-control" /></div> |
|
183 | -T, $render); |
|
184 | - } |
|
185 | - |
|
186 | - public function testItSetMinLengthConstraint(): void |
|
187 | - { |
|
188 | - $render = $this->getMock('foo', TextType::class, [ |
|
189 | - 'Constraints' => json_encode([ |
|
190 | - 'minlength' => 5, |
|
191 | - ]), |
|
192 | - ])->render(); |
|
193 | - |
|
194 | - $this->assertEquals(<<<'T' |
|
195 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" minlength="5" class="form-control" /></div> |
|
196 | -T, $render); |
|
197 | - } |
|
198 | - |
|
199 | - public function testItSetMaxLengthConstraint(): void |
|
200 | - { |
|
201 | - $render = $this->getMock('foo', TextType::class, [ |
|
202 | - 'Constraints' => json_encode([ |
|
203 | - 'maxlength' => 666, |
|
204 | - ]), |
|
205 | - ])->render(); |
|
206 | - |
|
207 | - $this->assertEquals(<<<'T' |
|
208 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" maxlength="666" class="form-control" /></div> |
|
209 | -T, $render); |
|
210 | - } |
|
211 | - |
|
212 | - public function testItSetLengthConstraint(): void |
|
213 | - { |
|
214 | - $render = $this->getMock('foo', TextType::class, [ |
|
215 | - 'Constraints' => json_encode([ |
|
216 | - 'length' => '[6,10]', |
|
217 | - ]), |
|
218 | - ])->render(); |
|
219 | - |
|
220 | - $this->assertEquals(<<<'T' |
|
221 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-length="[6,10]" class="form-control" /></div> |
|
222 | -T, $render); |
|
223 | - } |
|
224 | - |
|
225 | - public function testItSetMinConstraint(): void |
|
226 | - { |
|
227 | - $render = $this->getMock('foo', TextType::class, [ |
|
228 | - 'Constraints' => json_encode([ |
|
229 | - 'min' => 3, |
|
230 | - ]), |
|
231 | - ])->render(); |
|
232 | - |
|
233 | - $this->assertEquals(<<<'T' |
|
234 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" min="3" class="form-control" /></div> |
|
235 | -T, $render); |
|
236 | - } |
|
237 | - |
|
238 | - public function testItSetMaxConstraint(): void |
|
239 | - { |
|
240 | - $render = $this->getMock('foo', TextType::class, [ |
|
241 | - 'Constraints' => json_encode([ |
|
242 | - 'max' => 99, |
|
243 | - ]), |
|
244 | - ])->render(); |
|
245 | - |
|
246 | - $this->assertEquals(<<<'T' |
|
247 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" max="99" class="form-control" /></div> |
|
248 | -T, $render); |
|
249 | - } |
|
250 | - |
|
251 | - public function testItSetRangeConstraint(): void |
|
252 | - { |
|
253 | - $render = $this->getMock('foo', TextType::class, [ |
|
254 | - 'Constraints' => json_encode([ |
|
255 | - 'range' => '6,10', |
|
256 | - ]), |
|
257 | - ])->render(); |
|
258 | - |
|
259 | - $this->assertEquals(<<<'T' |
|
260 | -<div class="form-group"><label for="form_foo">Foo</label> <input type="range" id="form_foo" name="form[foo]" min="6" max="10" class="form-control" /></div> |
|
261 | -T, $render); |
|
262 | - } |
|
263 | - |
|
264 | - public function testItSetPatternConstraint(): void |
|
265 | - { |
|
266 | - $render = $this->getMock('foo', TextType::class, [ |
|
267 | - 'Constraints' => json_encode([ |
|
268 | - 'pattern' => "\+d", |
|
269 | - ]), |
|
270 | - ])->render(); |
|
271 | - |
|
272 | - $this->assertEquals(<<<'T' |
|
273 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" pattern="\+d" class="form-control" /></div> |
|
274 | -T, $render); |
|
275 | - } |
|
276 | - |
|
277 | - public function testItSetMinCheckConstraint(): void |
|
278 | - { |
|
279 | - $render = $this->getMock('foo', TextType::class, [ |
|
280 | - 'Constraints' => json_encode([ |
|
281 | - 'mincheck' => '3', |
|
282 | - ]), |
|
283 | - ])->render(); |
|
284 | - |
|
285 | - $this->assertEquals(<<<'T' |
|
286 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-mincheck="3" class="form-control" /></div> |
|
287 | -T, $render); |
|
288 | - } |
|
289 | - |
|
290 | - public function testItSetMaxCheckConstraint(): void |
|
291 | - { |
|
292 | - $render = $this->getMock('foo', TextType::class, [ |
|
293 | - 'Constraints' => json_encode([ |
|
294 | - 'maxcheck' => 5, |
|
295 | - ]), |
|
296 | - ])->render(); |
|
297 | - |
|
298 | - $this->assertEquals(<<<'T' |
|
299 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-maxcheck="5" class="form-control" /></div> |
|
300 | -T, $render); |
|
301 | - } |
|
302 | - |
|
303 | - public function testItSetCheckConstraint(): void |
|
304 | - { |
|
305 | - $render = $this->getMock('foo', TextType::class, [ |
|
306 | - 'Constraints' => json_encode([ |
|
307 | - 'check' => '[1,3]', |
|
308 | - ]), |
|
309 | - ])->render(); |
|
310 | - |
|
311 | - $this->assertEquals(<<<'T' |
|
312 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-check="[1,3]" class="form-control" /></div> |
|
313 | -T, $render); |
|
314 | - } |
|
315 | - |
|
316 | - public function testItSetEqualToConstraint(): void |
|
317 | - { |
|
318 | - $render = $this->getMock('foo', TextType::class, [ |
|
319 | - 'Constraints' => json_encode([ |
|
320 | - 'equalto' => '#another', |
|
321 | - ]), |
|
322 | - ])->render(); |
|
323 | - |
|
324 | - $this->assertEquals(<<<'T' |
|
325 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-equalto="#another" class="form-control" /></div> |
|
326 | -T, $render); |
|
327 | - } |
|
328 | - |
|
329 | - public function testItSetDataParsleyConstraint(): void |
|
330 | - { |
|
331 | - $render = $this->getMock('foo', TextType::class, [ |
|
332 | - 'Constraints' => json_encode([ |
|
333 | - 'data-parsley-validator-foo' => '#bar', |
|
334 | - ]), |
|
335 | - ])->render(); |
|
336 | - |
|
337 | - $this->assertEquals(<<<'T' |
|
338 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" data-parsley-validator-foo="#bar" class="form-control" /></div> |
|
339 | -T, $render); |
|
340 | - } |
|
341 | - |
|
342 | - public function testItSetHelp(): void |
|
343 | - { |
|
344 | - $render = $this->getMock('foo', TextType::class, [ |
|
345 | - 'Help' => 'A help block', |
|
346 | - ])->render(); |
|
347 | - |
|
348 | - $this->assertEquals(<<<'T' |
|
349 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted">A help block</small></div> |
|
350 | -T, $render); |
|
351 | - } |
|
352 | - |
|
353 | - public function testItSetHelpAttr(): void |
|
354 | - { |
|
355 | - $render = $this->getMock('foo', TextType::class, [ |
|
356 | - 'Help' => 'A help block', |
|
357 | - 'help_attr' => [ |
|
358 | - 'class' => 'help-class', |
|
359 | - ], |
|
360 | - ])->render(); |
|
361 | - |
|
362 | - $this->assertEquals(<<<'T' |
|
363 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="help-class form-text text-muted">A help block</small></div> |
|
364 | -T, $render); |
|
365 | - } |
|
366 | - |
|
367 | - public function testItSetHelpHtml(): void |
|
368 | - { |
|
369 | - $render = $this->getMock('foo', TextType::class, [ |
|
370 | - 'Help' => '<a href="link">A help block</a>', |
|
371 | - 'help_html' => true, |
|
372 | - ])->render(); |
|
373 | - |
|
374 | - $this->assertEquals(<<<'T' |
|
375 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" aria-describedby="form_foo_help" class="form-control" /><small id="form_foo_help" class="form-text text-muted"><a href="link">A help block</a></small></div> |
|
376 | -T, $render); |
|
377 | - } |
|
378 | - |
|
379 | - public function testItSetAttrExtra(): void |
|
380 | - { |
|
381 | - $render = $this->getMock('foo', TextType::class, [ |
|
382 | - 'attr' => [ |
|
383 | - 'class' => 'input-class', |
|
384 | - ], |
|
385 | - ])->render(); |
|
386 | - |
|
387 | - $this->assertEquals(<<<'T' |
|
388 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" /></div> |
|
389 | -T, $render); |
|
390 | - } |
|
391 | - |
|
392 | - public function testItSetAttrExtraWithEmptyData(): void |
|
393 | - { |
|
394 | - $render = $this->getMock('foo', TextType::class, [ |
|
395 | - 'attr' => [ |
|
396 | - 'class' => 'input-class', |
|
397 | - ], |
|
398 | - 'empty_data' => 'default', |
|
399 | - ])->render(); |
|
400 | - |
|
401 | - $this->assertEquals(<<<'T' |
|
402 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="input-class form-control" placeholder="default" /></div> |
|
403 | -T, $render); |
|
404 | - } |
|
405 | - |
|
406 | - public function testItSetEmptyDataWithAttrExtra(): void |
|
407 | - { |
|
408 | - $render = $this->getMock('foo', TextType::class, [ |
|
409 | - 'empty_data' => 'default', |
|
410 | - 'attr' => [ |
|
411 | - 'class' => 'input-class', |
|
412 | - ], |
|
413 | - ])->render(); |
|
414 | - |
|
415 | - $this->assertEquals(<<<'T' |
|
416 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="input-class form-control" /></div> |
|
417 | -T, $render); |
|
418 | - } |
|
419 | - |
|
420 | - public function testItSetDisabled(): void |
|
421 | - { |
|
422 | - $render = $this->getMock('foo', TextType::class, [ |
|
423 | - 'disabled' => true, |
|
424 | - ])->render(); |
|
425 | - |
|
426 | - $this->assertEquals(<<<'T' |
|
427 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" disabled="disabled" class="form-control" /></div> |
|
428 | -T, $render); |
|
429 | - } |
|
430 | - |
|
431 | - public function testItSetEmptyData(): void |
|
432 | - { |
|
433 | - $render = $this->getMock('foo', TextType::class, [ |
|
434 | - 'empty_data' => 'default', |
|
435 | - ])->render(); |
|
436 | - |
|
437 | - $this->assertEquals(<<<'T' |
|
438 | -<div class="form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" placeholder="default" class="form-control" /></div> |
|
439 | -T, $render); |
|
440 | - } |
|
441 | - |
|
442 | - public function testItSetRowAttr(): void |
|
443 | - { |
|
444 | - $this->markTestSkipped('Not works...'); |
|
445 | - |
|
446 | - $render = $this->getMock('foo', TextType::class, [ |
|
447 | - 'row_attr' => [ |
|
448 | - 'class' => 'row-class', |
|
449 | - ], |
|
450 | - ])->render(); |
|
451 | - |
|
452 | - $this->assertEquals(<<<'T' |
|
453 | -<div class="row-class form-group"><label for="form_foo">Foo</label><input type="text" id="form_foo" name="form[foo]" class="form-control" /></div> |
|
454 | -T, $render); |
|
455 | - } |
|
456 | - |
|
457 | - public function getDefaultWithSpacesOptions(): array |
|
458 | - { |
|
459 | - return [ |
|
460 | - ['foo bar'], |
|
461 | - ['foo bar'], |
|
462 | - [' foo bar '], |
|
463 | - [' foo bar'], |
|
464 | - ['foo bar '], |
|
465 | - [' foo bar '], |
|
466 | - ]; |
|
467 | - } |
|
468 | - |
|
469 | - public function getRequiredOptions(): array |
|
470 | - { |
|
471 | - return [ |
|
472 | - [\json_encode(['required'])], |
|
473 | - [\json_encode(['required' => true])], |
|
474 | - [\json_encode(['required' => 'true'])], |
|
475 | - [\json_encode(['required' => 'required'])], |
|
476 | - ['required'], |
|
477 | - ]; |
|
478 | - } |
|
479 | -} |