Пример #1
0
$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');
// ->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));