fix tests

This commit is contained in:
Christian Flothmann 2019-02-13 22:52:06 +01:00
parent c6a2c3348f
commit 1fe359995b
4 changed files with 228 additions and 76 deletions

View File

@ -2670,6 +2670,82 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
[@name="name"]
[@class="my&class form-control"]
[@value="#0000ff"]
'
);
}
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]"]
'
);
}

View File

@ -931,4 +931,80 @@ 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]"]
'
);
}
}

View File

@ -2587,82 +2587,6 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[@type="color"]
[@name="name"]
[@value="#0000ff"]
'
);
}
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]"]
'
);
}

View File

@ -533,4 +533,80 @@ 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]"]
'
);
}
}