RadioFieldTest.php 955 B

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