Skip to content

Commit aee39f1

Browse files
committed
(finally) fix version dependent Form tests
1 parent f114925 commit aee39f1

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

Tests/AbstractLayoutTest.php

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

Tests/Extension/Core/Type/BaseTypeTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public function testDefaultTranslationDomain()
124124

125125
public function testPassLabelTranslationParametersToView()
126126
{
127+
$this->requiresFeatureSet(403);
128+
127129
$view = $this->factory->create($this->getTestedType(), null, [
128130
'label_translation_parameters' => ['%param%' => 'value'],
129131
])
@@ -134,6 +136,8 @@ public function testPassLabelTranslationParametersToView()
134136

135137
public function testPassAttrTranslationParametersToView()
136138
{
139+
$this->requiresFeatureSet(403);
140+
137141
$view = $this->factory->create($this->getTestedType(), null, [
138142
'attr_translation_parameters' => ['%param%' => 'value'],
139143
])
@@ -144,6 +148,8 @@ public function testPassAttrTranslationParametersToView()
144148

145149
public function testInheritLabelTranslationParametersFromParent()
146150
{
151+
$this->requiresFeatureSet(403);
152+
147153
$view = $this->factory
148154
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
149155
'label_translation_parameters' => ['%param%' => 'value'],
@@ -157,6 +163,8 @@ public function testInheritLabelTranslationParametersFromParent()
157163

158164
public function testInheritAttrTranslationParametersFromParent()
159165
{
166+
$this->requiresFeatureSet(403);
167+
160168
$view = $this->factory
161169
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
162170
'attr_translation_parameters' => ['%param%' => 'value'],
@@ -170,6 +178,8 @@ public function testInheritAttrTranslationParametersFromParent()
170178

171179
public function testPreferOwnLabelTranslationParameters()
172180
{
181+
$this->requiresFeatureSet(403);
182+
173183
$view = $this->factory
174184
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
175185
'label_translation_parameters' => ['%parent_param%' => 'parent_value', '%override_param%' => 'parent_override_value'],
@@ -185,6 +195,8 @@ public function testPreferOwnLabelTranslationParameters()
185195

186196
public function testPreferOwnAttrTranslationParameters()
187197
{
198+
$this->requiresFeatureSet(403);
199+
188200
$view = $this->factory
189201
->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, [
190202
'attr_translation_parameters' => ['%parent_param%' => 'parent_value', '%override_param%' => 'parent_override_value'],
@@ -200,6 +212,8 @@ public function testPreferOwnAttrTranslationParameters()
200212

201213
public function testDefaultLabelTranslationParameters()
202214
{
215+
$this->requiresFeatureSet(403);
216+
203217
$view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE)
204218
->add('child', $this->getTestedType())
205219
->getForm()
@@ -210,6 +224,8 @@ public function testDefaultLabelTranslationParameters()
210224

211225
public function testDefaultAttrTranslationParameters()
212226
{
227+
$this->requiresFeatureSet(403);
228+
213229
$view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE)
214230
->add('child', $this->getTestedType())
215231
->getForm()

0 commit comments

Comments
 (0)