1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
use strict;
use warnings;
use Test::More tests => 3;
use HTML::FormFu;
use DateTime;
my $form = HTML::FormFu->new({ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } });
$form->load_config_file('t/elements/date_default_datetime_args.yml');
$form->process;
{
my $parser = DateTime::Format::Natural->new(
time_zone => 'Europe/Berlin',
);
my $dt = $parser->parse_datetime( 'now' );
my $foo = $form->get_field('foo');
my $year = $dt->year;
my $year_xhtml = qq{<option value="$year" selected="selected">$year</option>};
cmp_ok( $foo, '=~', $year_xhtml );
my $hour = sprintf "%02d", $dt->hour;
my $hour_xhtml = qq{<option value="$hour" selected="selected">$hour</option>};
cmp_ok( $foo, '=~', $hour_xhtml );
}
{
my $bar = $form->get_field('bar');
my $year_xhtml = qq{<option value="2001" selected="selected">2001</option>};
cmp_ok( $bar, '=~', $year_xhtml );
}
|