} } // __construct() $t->diag('__construct()'); $w = new MyWidgetForm(array('id_format' => '%s')); $t->is($w->render('foo'), '<input name="foo" id="foo" /><textarea name="foo" id="foo"></textarea>', '__construct() takes a id_format argument'); $t->is($w->render('foo', null, array('id' => 'id_foo')), '<input name="foo" id="id_foo" /><textarea name="foo" id="id_foo"></textarea>', '->render() id attributes takes precedence over auto generated ids'); $w = new MyWidgetForm(array('id_format' => false)); $t->is($w->render('foo'), '<input name="foo" /><textarea name="foo"></textarea>', '__construct() can disable id generation'); // ->getLabel() ->setLabel() $t->diag('->getLabel() ->setLabel()'); $w = new MyWidgetForm(); $t->is($w->getLabel(), null, '->getLabel() returns null if no label has been defined'); $w = new MyWidgetForm(array('label' => 'foo')); $t->is($w->getLabel(), 'foo', '->getLabel() returns the label'); $w->setLabel('bar'); $t->is($w->getLabel(), 'bar', '->setLabel() changes the label'); // ->getDefault() ->setDefault() $t->diag('->getDefault() ->setDefault()'); $w = new MyWidgetForm(); $t->is($w->getDefault(), null, '->getDefault() returns null if no default value has been defined'); $w = new MyWidgetForm(array('default' => 'foo')); $t->is($w->getDefault(), 'foo', '->getDefault() returns the default value'); $w->setDefault('bar'); $t->is($w->getDefault(), 'bar', '->setDefault() changes the default value for the widget'); // ->getParent() ->setParent() $t->diag('->getParent() ->setParent()'); $w = new MyWidgetForm(); $t->is($w->getParent(), null, '->getParent() returns null if no widget schema has been defined'); $w->setParent($ws = new sfWidgetFormSchema()); $t->is($w->getParent(), $ws, '->setParent() associates a widget schema to the widget');