RadioFieldTest.php 898 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Symfony\Tests\Component\Form;
  3. use Symfony\Component\Form\RadioField;
  4. use Symfony\Component\Form\FieldGroup;
  5. class RadioFieldTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testRender()
  8. {
  9. $field = new RadioField('name');
  10. $field->setData(true);
  11. $html = '<input id="name" name="name" checked="checked" type="radio" class="foobar" />';
  12. $this->assertEquals($html, $field->render(array(
  13. 'class' => 'foobar',
  14. )));
  15. }
  16. // when a radio button is in a field group, all radio buttons in that group
  17. // should have the same name
  18. public function testRenderParentName()
  19. {
  20. $field = new RadioField('name');
  21. $field->setParent(new FieldGroup('parent'));
  22. $html = '<input id="parent_name" name="parent" type="radio" />';
  23. $this->assertEquals($html, $field->render());
  24. }
  25. }