@@ -381,6 +381,25 @@ public function testLabelFormatOverriddenOption()
381
381
);
382
382
}
383
383
384
+ public function testLabelWithoutTranslationOnButton ()
385
+ {
386
+ $ form = $ this ->factory ->createNamedBuilder ('myform ' , 'Symfony\Component\Form\Extension\Core\Type\FormType ' , null , array (
387
+ 'translation_domain ' => false ,
388
+ ))
389
+ ->add ('mybutton ' , 'Symfony\Component\Form\Extension\Core\Type\ButtonType ' )
390
+ ->getForm ();
391
+ $ view = $ form ->get ('mybutton ' )->createView ();
392
+ $ html = $ this ->renderWidget ($ view );
393
+
394
+ $ this ->assertMatchesXpath ($ html ,
395
+ '/button
396
+ [@type="button"]
397
+ [@name="myform[mybutton]"]
398
+ [.="Mybutton"]
399
+ '
400
+ );
401
+ }
402
+
384
403
public function testLabelFormatOnButton ()
385
404
{
386
405
$ form = $ this ->factory ->createNamedBuilder ('myform ' )
@@ -549,6 +568,31 @@ public function testSingleChoiceWithoutTranslation()
549
568
);
550
569
}
551
570
571
+ public function testSingleChoiceWithPlaceholderWithoutTranslation ()
572
+ {
573
+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\ChoiceType ' , '&a ' , array (
574
+ 'choices ' => array ('&a ' => 'Choice&A ' , '&b ' => 'Choice&B ' ),
575
+ 'multiple ' => false ,
576
+ 'expanded ' => false ,
577
+ 'required ' => false ,
578
+ 'translation_domain ' => false ,
579
+ 'placeholder ' => 'Placeholder&Not&Translated ' ,
580
+ ));
581
+
582
+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), array (),
583
+ '/select
584
+ [@name="name"]
585
+ [not(@required)]
586
+ [
587
+ ./option[@value=""][not(@selected)][not(@disabled)][.="Placeholder&Not&Translated"]
588
+ /following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
589
+ /following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
590
+ ]
591
+ [count(./option)=3]
592
+ '
593
+ );
594
+ }
595
+
552
596
public function testSingleChoiceAttributes ()
553
597
{
554
598
$ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\ChoiceType ' , '&a ' , array (
@@ -998,6 +1042,32 @@ public function testSingleChoiceExpandedWithPlaceholder()
998
1042
);
999
1043
}
1000
1044
1045
+ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation ()
1046
+ {
1047
+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\ChoiceType ' , '&a ' , array (
1048
+ 'choices ' => array ('&a ' => 'Choice&A ' , '&b ' => 'Choice&B ' ),
1049
+ 'multiple ' => false ,
1050
+ 'expanded ' => true ,
1051
+ 'translation_domain ' => false ,
1052
+ 'placeholder ' => 'Placeholder&Not&Translated ' ,
1053
+ ));
1054
+
1055
+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), array (),
1056
+ '/div
1057
+ [
1058
+ ./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)]
1059
+ /following-sibling::label[@for="name_placeholder"][.="Placeholder&Not&Translated"]
1060
+ /following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
1061
+ /following-sibling::label[@for="name_0"][.="Choice&A"]
1062
+ /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
1063
+ /following-sibling::label[@for="name_1"][.="Choice&B"]
1064
+ /following-sibling::input[@type="hidden"][@id="name__token"]
1065
+ ]
1066
+ [count(./input)=4]
1067
+ '
1068
+ );
1069
+ }
1070
+
1001
1071
public function testSingleChoiceExpandedWithBooleanValue ()
1002
1072
{
1003
1073
$ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\ChoiceType ' , true , array (
@@ -2141,6 +2211,17 @@ public function testButtonLabelIsEmpty()
2141
2211
$ this ->assertSame ('' , $ this ->renderLabel ($ form ->createView ()));
2142
2212
}
2143
2213
2214
+ public function testButtonlabelWithoutTranslation ()
2215
+ {
2216
+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\ButtonType ' , null , array (
2217
+ 'translation_domain ' => false ,
2218
+ ));
2219
+
2220
+ $ this ->assertWidgetMatchesXpath ($ form ->createView (), array (),
2221
+ '/button[@type="button"][@name="name"][.="Name"] '
2222
+ );
2223
+ }
2224
+
2144
2225
public function testSubmit ()
2145
2226
{
2146
2227
$ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\SubmitType ' );
@@ -2349,4 +2430,20 @@ public function testTranslatedAttributes()
2349
2430
$ this ->assertMatchesXpath ($ html , '/form//input[@title="[trans]Foo[/trans]"] ' );
2350
2431
$ this ->assertMatchesXpath ($ html , '/form//input[@placeholder="[trans]Bar[/trans]"] ' );
2351
2432
}
2433
+
2434
+ public function testAttributesNotTranslatedWhenTranslationDomainIsFalse ()
2435
+ {
2436
+ $ view = $ this ->factory ->createNamedBuilder ('name ' , 'Symfony\Component\Form\Extension\Core\Type\FormType ' , null , array (
2437
+ 'translation_domain ' => false ,
2438
+ ))
2439
+ ->add ('firstName ' , 'Symfony\Component\Form\Extension\Core\Type\TextType ' , array ('attr ' => array ('title ' => 'Foo ' )))
2440
+ ->add ('lastName ' , 'Symfony\Component\Form\Extension\Core\Type\TextType ' , array ('attr ' => array ('placeholder ' => 'Bar ' )))
2441
+ ->getForm ()
2442
+ ->createView ();
2443
+
2444
+ $ html = $ this ->renderForm ($ view );
2445
+
2446
+ $ this ->assertMatchesXpath ($ html , '/form//input[@title="Foo"] ' );
2447
+ $ this ->assertMatchesXpath ($ html , '/form//input[@placeholder="Bar"] ' );
2448
+ }
2352
2449
}
0 commit comments