File: date_default_datetime_args.t

package info (click to toggle)
libhtml-formfu-perl 2.01000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,116 kB
  • ctags: 828
  • sloc: perl: 12,478; makefile: 7; sql: 5
file content (43 lines) | stat: -rw-r--r-- 964 bytes parent folder | download
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
42
43
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-aggregate/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 );
}