8000 minor #30232 [FrameworkBundle][TwigBridge] fix tests (xabbuh) · symfony/symfony@b5b547d · GitHub
[go: up one dir, main page]

Skip to content

Commit b5b547d

Browse files
committed
minor #30232 [FrameworkBundle][TwigBridge] fix tests (xabbuh)
This PR was merged into the 4.3-dev branch. Discussion ---------- [FrameworkBundle][TwigBridge] fix tests | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | | License | MIT | Doc PR | Commits ------- 1fe3599 fix tests
2 parents c6a2c33 + 1fe3599 commit b5b547d

File tree

4 files changed

+228
-76
lines changed

4 files changed

+228
-76
lines changed

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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', 'Symfon E864 y\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
}

src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,4 +931,80 @@ public function testWidgetContainerAttributeNameRepeatedIfTrue()
931931
// foo="foo"
932932
$this->assertContains('<div id="form" foo="foo">', $html);
933933
}
934+
935+
public function testLabelWithTranslationParameters()
936+
{
937+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
938+
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
939+
'label_translation_parameters' => [
940+
'%address%' => 'Paris, rue de la Paix',
941+
],
942+
]);
943+
944+
$this->assertMatchesXpath($html,
945+
'/label
946+
[@for="name"]
947+
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
948+
'
949+
);
950+
}
951+
952+
public function testHelpWithTranslationParameters()
953+
{
954+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
955+
'help' => 'for company %company%',
956+
'help_translation_parameters' => [
957+
'%company%' => 'ACME Ltd.',
958+
],
959+
]);
960+
$html = $this->renderHelp($form->createView());
961+
962+
$this->assertMatchesXpath($html,
963+
'/*
964+
[@id="name_help"]
965+
[.="[trans]for company ACME Ltd.[/trans]"]
966+
'
967+
);
968+
}
969+
970+
public function testAttributesWithTranslationParameters()
971+
{
972+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
973+
'attr' => [
974+
'title' => 'Message to %company%',
975+
'placeholder' => 'Enter a message to %company%',
976+
],
977+
'attr_translation_parameters' => [
978+
'%company%' => 'ACME Ltd.',
979+
],
980+
]);
981+
$html = $this->renderWidget($form->createView());
982+
983+
$this->assertMatchesXpath($html,
984+
'/input
985+
[@title="[trans]Message to ACME Ltd.[/trans]"]
986+
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
987+
'
988+
);
989+
}
990+
991+
public function testButtonWithTranslationParameters()
992+
{
993+
$form = $this->factory->createNamedBuilder('myform')
994+
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
995+
'label' => 'Submit to %company%',
996+
'label_translation_parameters' => [
997+
'%company%' => 'ACME Ltd.',
998+
],
999+
])
1000+
->getForm();
1001+
$view = $form->get('mybutton')->createView();
1002+
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
1003+
1004+
$this->assertMatchesXpath($html,
1005+
'/button
1006+
[.="[trans]Submit to ACME Ltd.[/trans]"]
1007+
'
1008+
);
1009+
}
9341010
}

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,82 +2587,6 @@ public function testColor()
25872587
[@type="color"]
25882588
[@name="name"]
25892589
[@value="#0000ff"]
2590-
'
2591-
);
2592-
}
2593-
2594-
public function testLabelWithTranslationParameters()
2595-
{
2596-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
2597-
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
2598-
'label_translation_parameters' => [
2599-
'%address%' => 'Paris, rue de la Paix',
2600-
],
2601-
]);
2602-
2603-
$this->assertMatchesXpath($html,
2604-
'/label
2605-
[@for="name"]
2606-
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
2607-
'
2608-
);
2609-
}
2610-
2611-
public function testHelpWithTranslationParameters()
2612-
{
2613-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
2614-
'help' => 'for company %company%',
2615-
'help_translation_parameters' => [
2616-
'%company%' => 'ACME Ltd.',
2617-
],
2618-
]);
2619-
$html = $this->renderHelp($form->createView());
2620-
2621-
$this->assertMatchesXpath($html,
2622-
'/*
2623-
[@id="name_help"]
2624-
[.="[trans]for company ACME Ltd.[/trans]"]
2625-
'
2626-
);
2627-
}
2628-
2629-
public function testAttributesWithTranslationParameters()
2630-
{
2631-
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
2632-
'attr' => [
2633-
'title' => 'Message to %company%',
2634-
'placeholder' => 'Enter a message to %company%',
2635-
],
2636-
'attr_translation_parameters' => [
2637-
'%company%' => 'ACME Ltd.',
2638-
],
2639-
]);
2640-
$html = $this->renderWidget($form->createView());
2641-
2642-
$this->assertMatchesXpath($html,
2643-
'/input
2644-
[@title="[trans]Message to ACME Ltd.[/trans]"]
2645-
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
2646-
'
2647-
);
2648-
}
2649-
2650-
public function testButtonWithTranslationParameters()
2651-
{
2652-
$form = $this->factory->createNamedBuilder('myform')
2653-
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
2654-
'label' => 'Submit to %company%',
2655-
'label_translation_parameters' => [
2656-
'%company%' => 'ACME Ltd.',
2657-
],
2658-
])
2659-
->getForm();
2660-
$view = $form->get('mybutton')->createView();
2661-
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
2662-
2663-
$this->assertMatchesXpath($html,
2664-
'/button
2665-
[.="[trans]Submit to ACME Ltd.[/trans]"]
26662590
'
26672591
);
26682592
}

src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,4 +533,80 @@ public function testWidgetContainerAttributeNameRepeatedIfTrue()
533533
// foo="foo"
534534
$this->assertContains('<table id="form" foo="foo">', $html);
535535
}
536+
537+
public function testLabelWithTranslationParameters()
538+
{
539+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
540+
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
541+
'label_translation_parameters' => [
542+
'%address%' => 'Paris, rue de la Paix',
543+
],
544+
]);
545+
546+
$this->assertMatchesXpath($html,
547+
'/label
548+
[@for="name"]
549+
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
550+
'
551+
);
552+
}
553+
554+
public function testHelpWithTranslationParameters()
555+
{
556+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
557+
'help' => 'for company %company%',
558+
'help_translation_parameters' => [
559+
'%company%' => 'ACME Ltd.',
560+
],
561+
]);
562+
$html = $this->renderHelp($form->createView());
563+
564+
$this->assertMatchesXpath($html,
565+
'/*
566+
[@id="name_help"]
567+
[.="[trans]for company ACME Ltd.[/trans]"]
568+
'
569+
);
570+
}
571+
572+
public function testAttributesWithTranslationParameters()
573+
{
574+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
575+
'attr' => [
576+
'title' => 'Message to %company%',
577+
'placeholder' => 'Enter a message to %company%',
578+
],
579+
'attr_translation_parameters' => [
580+
'%company%' => 'ACME Ltd.',
581+
],
582+
]);
583+
$html = $this->renderWidget($form->createView());
584+
585+
$this->assertMatchesXpath($html,
586+
'/input
587+
[@title="[trans]Message to ACME Ltd.[/trans]"]
588+
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
589+
'
590+
);
591+
}
592+
593+
public function testButtonWithTranslationParameters()
594+
{
595+
$form = $this->factory->createNamedBuilder('myform')
596+
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
597+
'label' => 'Submit to %company%',
598+
'label_translation_parameters' => [
599+
'%company%' => 'ACME Ltd.',
600+
],
601+
])
602+
->getForm();
603+
$view = $form->get('mybutton')->createView();
604+
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
605+
606+
$this->assertMatchesXpath($html,
607+
'/button
608+
[.="[trans]Submit to ACME Ltd.[/trans]"]
609+
'
610+
);
611+
}
536612
}

0 commit comments

Comments
 (0)
0