$t->is($w->getParent(), $ws, '->setParent() associates a widget schema to the widget'); // ->getIdFormat() ->setIdFormat() $t->diag('->getIdFormat() ->setIdFormat()'); $w = new MyWidgetForm(); $w->setIdFormat('id_%s'); $t->is($w->getIdFormat(), 'id_%s', '->setIdFormat() sets the format for the generated id attribute'); // ->isHidden() $t->diag('->isHidden()'); $t->is($w->isHidden(), false, '->isHidden() returns false if a widget is not hidden'); $w->setHidden(true); $t->is($w->isHidden(), true, '->isHidden() returns true if a widget is hidden'); // ->needsMultipartForm() $t->diag('->needsMultipartForm()'); $t->is($w->needsMultipartForm(), false, '->needsMultipartForm() returns false if the widget does not need a multipart form'); $w = new MyWidgetForm(array('needs_multipart' => true)); $t->is($w->needsMultipartForm(), true, '->needsMultipartForm() returns false if the widget needs a multipart form'); // ->renderTag() $t->diag('->renderTag()'); $w = new MyWidgetForm(); $t->is($w->renderTag('input'), '<input />', '->renderTag() does not add an id if no name is given'); $t->is($w->renderTag('input', array('id' => 'foo')), '<input id="foo" />', '->renderTag() does not add an id if one is given'); $t->is($w->renderTag('input', array('name' => 'foo')), '<input name="foo" id="foo" />', '->renderTag() adds an id if none is given and a name is given'); $w->setIdFormat('id_%s'); $t->is($w->renderTag('input', array('name' => 'foo')), '<input name="foo" id="id_foo" />', '->renderTag() uses the id_format to generate an id'); sfWidget::setXhtml(false); $t->is($w->renderTag('input'), '<input>', '->renderTag() does not close tag if not in XHTML mode'); sfWidget::setXhtml(true); // ->renderContentTag() $t->diag('->renderContentTag()'); $w = new MyWidgetForm(); $t->is($w->renderContentTag('textarea'), '<textarea></textarea>', '->renderContentTag() does not add an id if no name is given');