$t->is($w->getFormFormatterName(), 'table', '__construct() sets "form_formatter" option to "table" by default'); $w = new sfWidgetFormSchema(array(), array('form_formatter' => 'list')); $t->is($w->getFormFormatterName(), 'list', '__construct() can override the default value for the "form_formatter" option'); $t->is($w->getNameFormat(), '%s', '__construct() sets "name_format" option to "table" by default'); $w = new sfWidgetFormSchema(array(), array('name_format' => 'name_%s')); $t->is($w->getNameFormat(), 'name_%s', '__construct() can override the default value for the "name_format" option'); // implements ArrayAccess $t->diag('implements ArrayAccess'); $w = new sfWidgetFormSchema(); $w['w1'] = $w1; $w['w2'] = $w2; $w1->setParent($w); $w2->setParent($w); $t->ok($w->getFields() == array('w1' => $w1, 'w2' => $w2), 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); $t->is($w1->getParent(), $w, 'The widget schema is associated with the fields'); $t->is($w2->getParent(), $w, 'The widget schema is associated with the fields'); try { $w['w1'] = 'string'; $t->fail('sfWidgetFormSchema implements the ArrayAccess interface for the fields'); } catch (LogicException $e) { $t->pass('sfWidgetFormSchema implements the ArrayAccess interface for the fields'); } $w = new sfWidgetFormSchema(array('w1' => $w1)); $t->is(isset($w['w1']), true, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); $t->is(isset($w['w2']), false, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); $w = new sfWidgetFormSchema(array('w1' => $w1)); $w1->setParent($w); $w2->setParent($w); $t->ok($w['w1'] == $w1, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); $t->is($w['w2'], null, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); $w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2));