Ejemplo n.º 1
0
    $t->fail('__construct() throws a InvalidArgumentException if the date/time options is not an array');
} catch (InvalidArgumentException $e) {
    $t->pass('__construct() throws a InvalidArgumentException if the date/time options is not an array');
}
// attributes
$t->diag('attributes');
$w = new sfWidgetFormDateTime();
$dom->loadHTML($w->render('foo', $year . '-10-15 12:30:35', array('date' => array('disabled' => 'disabled'), 'time' => array('disabled' => 'disabled'))));
$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 5, '->render() takes the attributes into account for all the five embedded widgets');
$w->setAttribute('date', array('disabled' => 'disabled'));
$w->setAttribute('time', array('disabled' => 'disabled'));
$dom->loadHTML($w->render('foo', $year . '-10-15 12:30:35'));
$t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 5, '->render() takes the attributes into account for all the five embedded widgets');
// id_format
$t->diag('id_format');
$w = new sfWidgetFormDateTime();
$w->setIdFormat('id_%s');
$dom->loadHTML($w->render('foo'));
$t->is(count($css->matchAll('#id_foo_month')), 1, '->render() month considers id_format');
$t->is(count($css->matchAll('#id_foo_day')), 1, '->render() day considers id_format');
$t->is(count($css->matchAll('#id_foo_year')), 1, '->render() year considers id_format');
$t->is(count($css->matchAll('#id_foo_hour')), 1, '->render() hour considers id_format');
$t->is(count($css->matchAll('#id_foo_minute')), 1, '->render() minute considers id_format');
$w->setOption('date', array('id_format' => 'override_%s'));
$w->setOption('time', array('id_format' => 'override_%s'));
$dom->loadHTML($w->render('foo'));
$t->is(count($css->matchAll('#override_foo_month')), 1, '->render() month does not override subwidget id_format');
$t->is(count($css->matchAll('#override_foo_day')), 1, '->render() day does not override subwidget id_format');
$t->is(count($css->matchAll('#override_foo_year')), 1, '->render() year does not override subwidget id_format');
$t->is(count($css->matchAll('#override_foo_hour')), 1, '->render() hour does not override subwidget id_format');
$t->is(count($css->matchAll('#override_foo_minute')), 1, '->render() minute does not override subwidget id_format');