Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87d87e7

Browse files
configure "empty_data" option in tests
1 parent 3b799a0 commit 87d87e7

14 files changed

+613
-149
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public function testLabelOnForm()
3030

3131
public function testLabelDoesNotRenderFieldAttributes()
3232
{
33-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
33+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
34+
'empty_data' => null,
35+
]);
3436
$html = $this->renderLabel($form->createView(), null, [
3537
'attr' => [
3638
'class' => 'my&class',
@@ -47,7 +49,9 @@ public function testLabelDoesNotRenderFieldAttributes()
4749

4850
public function testLabelWithCustomAttributesPassedDirectly()
4951
{
50-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
52+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
53+
'empty_data' => null,
54+
]);
5155
$html = $this->renderLabel($form->createView(), null, [
5256
'label_attr' => [
5357
'class' => 'my&class',
@@ -64,7 +68,9 @@ public function testLabelWithCustomAttributesPassedDirectly()
6468

6569
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
6670
{
67-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
71+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
72+
'empty_data' => null,
73+
]);
6874
$html = $this->renderLabel($form->createView(), 'Custom label', [
6975
'label_attr' => [
7076
'class' => 'my&class',
@@ -83,6 +89,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
8389
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
8490
{
8591
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
92+
'empty_data' => null,
8693
'label' => 'Custom label',
8794
]);
8895
$html = $this->renderLabel($form->createView(), null, [
@@ -103,6 +110,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly
103110
public function testLabelHtmlDefaultIsFalse()
104111
{
105112
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
113+
'empty_data' => null,
106114
'label' => '<b>Bolded label</b>',
107115
]);
108116

@@ -119,6 +127,7 @@ public function testLabelHtmlDefaultIsFalse()
119127
public function testLabelHtmlIsTrue()
120128
{
121129
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
130+
'empty_data' => null,
122131
'label' => '<b>Bolded label</b>',
123132
'label_html' => true,
124133
]);

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public function testLabelOnForm()
3636

3737
public function testLabelDoesNotRenderFieldAttributes()
3838
{
39-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
39+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
40+
'empty_data' => null,
41+
]);
4042
$html = $this->renderLabel($form->createView(), null, [
4143
'attr' => [
4244
'class' => 'my&class',
@@ -53,7 +55,9 @@ public function testLabelDoesNotRenderFieldAttributes()
5355

5456
public function testLabelWithCustomAttributesPassedDirectly()
5557
{
56-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
58+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
59+
'empty_data' => null,
60+
]);
5761
$html = $this->renderLabel($form->createView(), null, [
5862
'label_attr' => [
5963
'class' => 'my&class',
@@ -70,7 +74,9 @@ public function testLabelWithCustomAttributesPassedDirectly()
7074

7175
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
7276
{
73-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
77+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
78+
'empty_data' => null,
79+
]);
7480
$html = $this->renderLabel($form->createView(), 'Custom label', [
7581
'label_attr' => [
7682
'class' => 'my&class',
@@ -89,6 +95,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
8995
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
9096
{
9197
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
98+
'empty_data' => null,
9299
'label' => 'Custom label',
93100
]);
94101
$html = $this->renderLabel($form->createView(), null, [
@@ -109,6 +116,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly
109116
public function testLabelHtmlDefaultIsFalse()
110117
{
111118
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
119+
'empty_data' => null,
112120
'label' => '<b>Bolded label</b>',
113121
]);
114122

@@ -125,6 +133,7 @@ public function testLabelHtmlDefaultIsFalse()
125133
public function testLabelHtmlIsTrue()
126134
{
127135
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
136+
'empty_data' => null,
128137
'label' => '<b>Bolded label</b>',
129138
'label_html' => true,
130139
]);
@@ -142,6 +151,7 @@ public function testLabelHtmlIsTrue()
142151
public function testHelp()
143152
{
144153
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
154+
'empty_data' => null,
145155
'help' => 'Help text test!',
146156
]);
147157
$view = $form->createView();
@@ -159,6 +169,7 @@ public function testHelp()
159169
public function testHelpAttr()
160170
{
161171
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
172+
'empty_data' => null,
162173
'help' => 'Help text test!',
163174
'help_attr' => [
164175
'class' => 'class-test',
@@ -179,6 +190,7 @@ public function testHelpAttr()
179190
public function testHelpHtmlDefaultIsFalse()
180191
{
181192
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
193+
'empty_data' => null,
182194
'help' => 'Help <b>text</b> test!',
183195
]);
184196

@@ -206,6 +218,7 @@ public function testHelpHtmlDefaultIsFalse()
206218
public function testHelpHtmlIsFalse()
207219
{
208220
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
221+
'empty_data' => null,
209222
'help' => 'Help <b>text</b> test!',
210223
'help_html' => false,
211224
]);
@@ -234,6 +247,7 @@ public function testHelpHtmlIsFalse()
234247
public function testHelpHtmlIsTrue()
235248
{
236249
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
250+
'empty_data' => null,
237251
'help' => 'Help <b>text</b> test!',
238252
'help_html' => true,
239253
]);
@@ -261,7 +275,9 @@ public function testHelpHtmlIsTrue()
261275

262276
public function testErrors()
263277
{
264-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
278+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
279+
'empty_data' => null,
280+
]);
265281
$form->addError(new FormError('[trans]Error 1[/trans]'));
266282
$form->addError(new FormError('[trans]Error 2[/trans]'));
267283
$view = $form->createView();
@@ -294,7 +310,9 @@ public function testErrors()
294310
public function testOverrideWidgetBlock()
295311
{
296312
// see custom_widgets.html.twig
297-
$form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType');
313+
$form = $this->factory->createNamed('text_id', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
314+
'empty_data' => null,
315+
]);
298316
$html = $this->renderWidget($form->createView());
299317

300318
$this->assertMatchesXpath($html,
@@ -1972,7 +1990,9 @@ public function testBirthDayWithPlaceholder()
19721990

19731991
public function testEmail()
19741992
{
1975-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar');
1993+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', [
1994+
'empty_data' => null,
1995+
]);
19761996

19771997
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
19781998
'/input
@@ -1988,6 +2008,7 @@ public function testEmail()
19882008
public function testEmailWithMaxLength()
19892009
{
19902010
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\EmailType', 'foo&bar', [
2011+
'empty_data' => null,
19912012
'attr' => ['maxlength' => 123],
19922013
]);
19932014

@@ -2019,6 +2040,7 @@ public function testHidden()
20192040
public function testDisabled()
20202041
{
20212042
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
2043+
'empty_data' => null,
20222044
'disabled' => true,
20232045
]);
20242046

@@ -2165,7 +2187,9 @@ public function testRenderNumberWithHtml5NumberType()
21652187

21662188
public function testPassword()
21672189
{
2168-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar');
2190+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', [
2191+
'empty_data' => null,
2192+
]);
21692193

21702194
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
21712195
'/input
@@ -2179,6 +2203,7 @@ public function testPassword()
21792203
public function testPasswordSubmittedWithNotAlwaysEmpty()
21802204
{
21812205
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, [
2206+
'empty_data' => null,
21822207
'always_empty' => false,
21832208
]);
21842209
$form->submit('foo&bar');
@@ -2196,6 +2221,7 @@ public function testPasswordSubmittedWithNotAlwaysEmpty()
21962221
public function testPasswordWithMaxLength()
21972222
{
21982223
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', 'foo&bar', [
2224+
'empty_data' => null,
21992225
'attr' => ['maxlength' => 123],
22002226
]);
22012227

@@ -2355,7 +2381,10 @@ public function testRadioRowWithHelp()
23552381

23562382
public function testRange()
23572383
{
2358-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5]]);
2384+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, [
2385+
'empty_data' => null,
2386+
'attr' => ['min' => 5],
2387+
]);
23592388

23602389
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
23612390
'/input
@@ -2370,7 +2399,10 @@ public function testRange()
23702399

23712400
public function testRangeWithMinMaxValues()
23722401
{
2373-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5, 'max' => 57]]);
2402+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, [
2403+
'empty_data' => null,
2404+
'attr' => ['min' => 5, 'max' => 57],
2405+
]);
23742406

23752407
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
23762408
'/input
@@ -2387,6 +2419,7 @@ public function testRangeWithMinMaxValues()
23872419
public function testTextarea()
23882420
{
23892421
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', 'foo&bar', [
2422+
'empty_data' => null,
23902423
'attr' => ['pattern' => 'foo'],
23912424
]);
23922425

@@ -2402,7 +2435,9 @@ public function testTextarea()
24022435

24032436
public function testText()
24042437
{
2405-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar');
2438+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', [
2439+
'empty_data' => null,
2440+
]);
24062441

24072442
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
24082443
'/input
@@ -2418,6 +2453,7 @@ public function testText()
24182453
public function testTextWithMaxLength()
24192454
{
24202455
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'foo&bar', [
2456+
'empty_data' => null,
24212457
'attr' => ['maxlength' => 123],
24222458
]);
24232459

@@ -2434,7 +2470,9 @@ public function testTextWithMaxLength()
24342470

24352471
public function testSearch()
24362472
{
2437-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar');
2473+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\SearchType', 'foo&bar', [
2474+
'empty_data' => null,
2475+
]);
24382476

24392477
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
24402478
'/input
@@ -2648,7 +2686,10 @@ public function testTimezoneWithPlaceholder()
26482686
public function testUrlWithDefaultProtocol()
26492687
{
26502688
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';
2651-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => 'http']);
2689+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, [
2690+
'empty_data' => null,
2691+
'default_protocol' => 'http',
2692+
]);
26522693

26532694
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
26542695
'/input
@@ -2664,7 +2705,10 @@ public function testUrlWithDefaultProtocol()
26642705
public function testUrlWithoutDefaultProtocol()
26652706
{
26662707
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';
2667-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => null]);
2708+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, [
2709+
'empty_data' => null,
2710+
'default_protocol' => null,
2711+
]);
26682712

26692713
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
26702714
'/input
@@ -2742,6 +2786,7 @@ public function testReset()
27422786
public function testWidgetAttributes()
27432787
{
27442788
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', [
2789+
'empty_data' => null,
27452790
'required' => true,
27462791
'disabled' => true,
27472792
'attr' => ['readonly' => true, 'maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'],
@@ -2756,6 +2801,7 @@ public function testWidgetAttributes()
27562801
public function testWidgetAttributeNameRepeatedIfTrue()
27572802
{
27582803
$form = $this->factory->createNamed('text', 'Symfony\Component\Form\Extension\Core\Type\TextType', 'value', [
2804+
'empty_data' => null,
27592805
'attr' => ['foo' => true],
27602806
]);
27612807

@@ -2793,7 +2839,9 @@ public function testButtonAttributeNameRepeatedIfTrue()
27932839
public function testTel()
27942840
{
27952841
$tel = '0102030405';
2796-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TelType', $tel);
2842+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TelType', $tel, [
2843+
'empty_data' => null,
2844+
]);
27972845

27982846
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
27992847
'/input
@@ -2808,7 +2856,9 @@ public function testTel()
28082856
public function testColor()
28092857
{
28102858
$color = '#0000ff';
2811-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ColorType', $color);
2859+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ColorType', $color, [
2860+
'empty_data' => null,
2861+
]);
28122862

28132863
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
28142864
'/input

0 commit comments

Comments
 (0)