|
@@ -93,7 +93,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
abstract protected function renderEnctype(FormView $view);
|
|
|
|
|
|
- abstract protected function renderLabel(FormView $view, $label = null);
|
|
|
+ abstract protected function renderLabel(FormView $view, $label = null, array $vars = array());
|
|
|
|
|
|
abstract protected function renderErrors(FormView $view);
|
|
|
|
|
@@ -173,6 +173,61 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public function testLabelWithCustomTextPassedAsOptionAndDirectly()
|
|
|
+ {
|
|
|
+ $form = $this->factory->createNamed('text', 'na&me', null, array(
|
|
|
+ 'property_path' => 'name',
|
|
|
+ 'label' => 'Custom label',
|
|
|
+ ));
|
|
|
+ $html = $this->renderLabel($form->createView(), 'Overridden label');
|
|
|
+
|
|
|
+ $this->assertMatchesXpath($html,
|
|
|
+'/label
|
|
|
+ [@for="na&me"]
|
|
|
+ [.="[trans]Overridden label[/trans]"]
|
|
|
+'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testLabelWithCustomOptionsPassedDirectly()
|
|
|
+ {
|
|
|
+ $form = $this->factory->createNamed('text', 'na&me', null, array(
|
|
|
+ 'property_path' => 'name',
|
|
|
+ ));
|
|
|
+ $html = $this->renderLabel($form->createView(), null, array(
|
|
|
+ 'attr' => array(
|
|
|
+ 'class' => 'my&class'
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->assertMatchesXpath($html,
|
|
|
+'/label
|
|
|
+ [@for="na&me"]
|
|
|
+ [@class="my&class"]
|
|
|
+'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testLabelWithCustomTextAndCustomOptionsPassedDirectly()
|
|
|
+ {
|
|
|
+ $form = $this->factory->createNamed('text', 'na&me', null, array(
|
|
|
+ 'property_path' => 'name',
|
|
|
+ ));
|
|
|
+ $html = $this->renderLabel($form->createView(), 'Custom label', array(
|
|
|
+ 'attr' => array(
|
|
|
+ 'class' => 'my&class'
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->assertMatchesXpath($html,
|
|
|
+'/label
|
|
|
+ [@for="na&me"]
|
|
|
+ [@class="my&class"]
|
|
|
+ [.="[trans]Custom label[/trans]"]
|
|
|
+'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
public function testErrors()
|
|
|
{
|
|
|
$form = $this->factory->createNamed('text', 'na&me', null, array(
|