Explorar el Código

add test for label rendering

This should make test for #3127 easier to write.
Grégoire Paris hace 9 años
padre
commit
974d6150f9

+ 3 - 2
Tests/Form/Widget/BaseWidgetTest.php

@@ -100,9 +100,10 @@ abstract class BaseWidgetTest extends TypeTestCase
             'inline'            => 'natural',
             'field_description' => null,
             'block_name'        => false,
-            'options'           => array(),
+            'options'           => array(
+                'form_type' => 'vertical',
+            ),
         );
-
     }
 
     /**

+ 24 - 0
Tests/Form/Widget/FormChoiceWidgetTest.php

@@ -22,6 +22,30 @@ class FormChoiceWidgetTest extends BaseWidgetTest
         parent::setUp();
     }
 
+    public function testLabelRendering()
+    {
+        $choices = array('some', 'choices');
+        if (!method_exists('Symfony\Component\Form\FormTypeInterface', 'setDefaultOptions')) {
+            $choices = array_flip($choices);
+        }
+
+        $choice = $this->factory->create(
+            $this->getChoiceClass(),
+            null,
+            $this->getDefaultOption() + array(
+                'multiple' => true,
+                'expanded' => true,
+            ) + compact('choices')
+        );
+
+        $html = $this->renderWidget($choice->createView());
+
+        $this->assertContains(
+            '<span>[trans]some[/trans]</span>',
+            $this->cleanHtmlWhitespace($html)
+        );
+    }
+
     public function testDefaultValueRendering()
     {
         $choice = $this->factory->create(