@@ -2670,6 +2670,82 @@ public function testColor()
26702670 [@name="name"]
26712671 [@class="my&class form-control"]
26722672 [@value="#0000ff"]
2673+ '
2674+ );
2675+ }
2676+
2677+ public function testLabelWithTranslationParameters ()
2678+ {
2679+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\TextType ' );
2680+ $ html = $ this ->renderLabel ($ form ->createView (), 'Address is %address% ' , [
2681+ 'label_translation_parameters ' => [
2682+ '%address% ' => 'Paris, rue de la Paix ' ,
2683+ ],
2684+ ]);
2685+
2686+ $ this ->assertMatchesXpath ($ html ,
2687+ '/label
2688+ [@for="name"]
2689+ [.="[trans]Address is Paris, rue de la Paix[/trans]"]
2690+ '
2691+ );
2692+ }
2693+
2694+ public function testHelpWithTranslationParameters ()
2695+ {
2696+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\TextType ' , null , [
2697+ 'help ' => 'for company %company% ' ,
2698+ 'help_translation_parameters ' => [
2699+ '%company% ' => 'ACME Ltd. ' ,
2700+ ],
2701+ ]);
2702+ $ html = $ this ->renderHelp ($ form ->createView ());
2703+
2704+ $ this ->assertMatchesXpath ($ html ,
2705+ '/*
2706+ [@id="name_help"]
2707+ [.="[trans]for company ACME Ltd.[/trans]"]
2708+ '
2709+ );
2710+ }
2711+
2712+ public function testAttributesWithTranslationParameters ()
2713+ {
2714+ $ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\TextType ' , null , [
2715+ 'attr ' => [
2716+ 'title ' => 'Message to %company% ' ,
2717+ 'placeholder ' => 'Enter a message to %company% ' ,
2718+ ],
2719+ 'attr_translation_parameters ' => [
2720+ '%company% ' => 'ACME Ltd. ' ,
2721+ ],
2722+ ]);
2723+ $ html = $ this ->renderWidget ($ form ->createView ());
2724+
2725+ $ this ->assertMatchesXpath ($ html ,
2726+ '/input
2727+ [@title="[trans]Message to ACME Ltd.[/trans]"]
2728+ [@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
2729+ '
2730+ );
2731+ }
2732+
2733+ public function testButtonWithTranslationParameters ()
2734+ {
2735+ $ form = $ this ->factory ->createNamedBuilder ('myform ' )
2736+ ->add ('mybutton ' , 'Symfony\Component\Form\Extension\Core\Type\ButtonType ' , [
2737+ 'label ' => 'Submit to %company% ' ,
2738+ 'label_translation_parameters ' => [
2739+ '%company% ' => 'ACME Ltd. ' ,
2740+ ],
2741+ ])
2742+ ->getForm ();
2743+ $ view = $ form ->get ('mybutton ' )->createView ();
2744+ $ html = $ this ->renderWidget ($ view , ['label_format ' => 'form.%name% ' ]);
2745+
2746+ $ this ->assertMatchesXpath ($ html ,
2747+ '/button
2748+ [.="[trans]Submit to ACME Ltd.[/trans]"]
26732749 '
26742750 );
26752751 }
0 commit comments