minor #30238 properly move test methods (xabbuh)
This PR was merged into the 4.3-dev branch.
Discussion
----------
properly move test methods
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
6bfc5f0901
properly move test methods
This commit is contained in:
commit
401cf8712d
@ -293,6 +293,82 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
|
||||
'label_translation_parameters' => [
|
||||
'%address%' => 'Paris, rue de la Paix',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'for company %company%',
|
||||
'help_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderHelp($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/*
|
||||
[@id="name_help"]
|
||||
[.="[trans]for company ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'attr' => [
|
||||
'title' => 'Message to %company%',
|
||||
'placeholder' => 'Enter a message to %company%',
|
||||
],
|
||||
'attr_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderWidget($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@title="[trans]Message to ACME Ltd.[/trans]"]
|
||||
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testButtonWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('myform')
|
||||
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
|
||||
'label' => 'Submit to %company%',
|
||||
'label_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
$view = $form->get('mybutton')->createView();
|
||||
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/button
|
||||
[.="[trans]Submit to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form', $vars);
|
||||
|
@ -179,6 +179,82 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
|
||||
'label_translation_parameters' => [
|
||||
'%address%' => 'Paris, rue de la Paix',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'for company %company%',
|
||||
'help_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderHelp($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/*
|
||||
[@id="name_help"]
|
||||
[.="[trans]for company ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'attr' => [
|
||||
'title' => 'Message to %company%',
|
||||
'placeholder' => 'Enter a message to %company%',
|
||||
],
|
||||
'attr_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderWidget($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@title="[trans]Message to ACME Ltd.[/trans]"]
|
||||
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testButtonWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('myform')
|
||||
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
|
||||
'label' => 'Submit to %company%',
|
||||
'label_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
$view = $form->get('mybutton')->createView();
|
||||
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/button
|
||||
[.="[trans]Submit to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form', $vars);
|
||||
|
@ -193,6 +193,82 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
|
||||
'label_translation_parameters' => [
|
||||
'%address%' => 'Paris, rue de la Paix',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'for company %company%',
|
||||
'help_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderHelp($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/*
|
||||
[@id="name_help"]
|
||||
[.="[trans]for company ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'attr' => [
|
||||
'title' => 'Message to %company%',
|
||||
'placeholder' => 'Enter a message to %company%',
|
||||
],
|
||||
'attr_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderWidget($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@title="[trans]Message to ACME Ltd.[/trans]"]
|
||||
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testButtonWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('myform')
|
||||
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
|
||||
'label' => 'Submit to %company%',
|
||||
'label_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
$view = $form->get('mybutton')->createView();
|
||||
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/button
|
||||
[.="[trans]Submit to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->form($view, $vars);
|
||||
|
@ -71,6 +71,82 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testLabelWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
|
||||
'label_translation_parameters' => [
|
||||
'%address%' => 'Paris, rue de la Paix',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'for company %company%',
|
||||
'help_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderHelp($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/*
|
||||
[@id="name_help"]
|
||||
[.="[trans]for company ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'attr' => [
|
||||
'title' => 'Message to %company%',
|
||||
'placeholder' => 'Enter a message to %company%',
|
||||
],
|
||||
'attr_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderWidget($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@title="[trans]Message to ACME Ltd.[/trans]"]
|
||||
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testButtonWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('myform')
|
||||
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
|
||||
'label' => 'Submit to %company%',
|
||||
'label_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
$view = $form->get('mybutton')->createView();
|
||||
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/button
|
||||
[.="[trans]Submit to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
// should be moved to the Form component once absolute file paths are supported
|
||||
|
@ -931,80 +931,4 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest
|
||||
// foo="foo"
|
||||
$this->assertContains('<div id="form" foo="foo">', $html);
|
||||
}
|
||||
|
||||
public function testLabelWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
|
||||
'label_translation_parameters' => [
|
||||
'%address%' => 'Paris, rue de la Paix',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'for company %company%',
|
||||
'help_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderHelp($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/*
|
||||
[@id="name_help"]
|
||||
[.="[trans]for company ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'attr' => [
|
||||
'title' => 'Message to %company%',
|
||||
'placeholder' => 'Enter a message to %company%',
|
||||
],
|
||||
'attr_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderWidget($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@title="[trans]Message to ACME Ltd.[/trans]"]
|
||||
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testButtonWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('myform')
|
||||
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
|
||||
'label' => 'Submit to %company%',
|
||||
'label_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
$view = $form->get('mybutton')->createView();
|
||||
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/button
|
||||
[.="[trans]Submit to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -533,80 +533,4 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest
|
||||
// foo="foo"
|
||||
$this->assertContains('<table id="form" foo="foo">', $html);
|
||||
}
|
||||
|
||||
public function testLabelWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$html = $this->renderLabel($form->createView(), 'Address is %address%', [
|
||||
'label_translation_parameters' => [
|
||||
'%address%' => 'Paris, rue de la Paix',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/label
|
||||
[@for="name"]
|
||||
[.="[trans]Address is Paris, rue de la Paix[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'for company %company%',
|
||||
'help_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderHelp($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/*
|
||||
[@id="name_help"]
|
||||
[.="[trans]for company ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAttributesWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'attr' => [
|
||||
'title' => 'Message to %company%',
|
||||
'placeholder' => 'Enter a message to %company%',
|
||||
],
|
||||
'attr_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
]);
|
||||
$html = $this->renderWidget($form->createView());
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@title="[trans]Message to ACME Ltd.[/trans]"]
|
||||
[@placeholder="[trans]Enter a message to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testButtonWithTranslationParameters()
|
||||
{
|
||||
$form = $this->factory->createNamedBuilder('myform')
|
||||
->add('mybutton', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', [
|
||||
'label' => 'Submit to %company%',
|
||||
'label_translation_parameters' => [
|
||||
'%company%' => 'ACME Ltd.',
|
||||
],
|
||||
])
|
||||
->getForm();
|
||||
$view = $form->get('mybutton')->createView();
|
||||
$html = $this->renderWidget($view, ['label_format' => 'form.%name%']);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/button
|
||||
[.="[trans]Submit to ACME Ltd.[/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user