File: date_default_datetime_args.t

package info (click to toggle)
libhtml-formfu-perl 2.07000-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,396 kB
  • sloc: perl: 12,777; makefile: 9; sql: 5
file content (43 lines) | stat: -rw-r--r-- 954 bytes parent folder | download | duplicates (3)
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/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="2004" selected="selected">2004</option>};

    cmp_ok( $bar, '=~', $year_xhtml );
}