File: select2.t

package info (click to toggle)
libhtml-formhandler-perl 0.40057-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,320 kB
  • ctags: 685
  • sloc: perl: 8,849; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (4)
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
44
use strict;
use warnings;
use Test::More;

{
    package MyApp::Test;
    use Moose;
    with 'HTML::FormHandler::TraitFor::Types';

    has 'foo' => (
        is => 'rw',
        isa => 'HFH::SelectOptions',
        coerce => 1,
    );
}

my $obj = MyApp::Test->new( foo => [ 1 => 'One', 2 => 'Two', 3 => 'Three' ] );

is_deeply( $obj->foo,
    [ { value => 1, label => 'One' }, { value => 2, label => 'Two' }, { value => 3, label => 'Three' } ],
    'value of foo is correct' );


{
    package MyApp::Form::Test;
    use HTML::FormHandler::Moose;
    extends 'HTML::FormHandler';

    has_field 'foo' => (
        type => 'Select',
        options => [
            1 => 'One',
            2 => 'Two',
            3 => 'Three',
        ],
    );
    has_field 'bar';

}

my $form = MyApp::Form::Test->new;
ok( $form );

done_testing;