File: date_default_datetime_args.t

package info (click to toggle)
libhtml-formfu-perl 0.07002-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,928 kB
  • ctags: 989
  • sloc: perl: 12,036; makefile: 9; sql: 5
file content (39 lines) | stat: -rw-r--r-- 967 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
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;
    my $dt     = $parser->parse_datetime( 'now' );
    $dt->set_time_zone( 'Europe/Berlin' );

    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 );
}