File: enum_select.t

package info (click to toggle)
libhtml-formfu-model-dbic-perl 2.03-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,148 kB
  • sloc: perl: 1,429; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 833 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
44
45
46
47
use strict;
use warnings;
use Test::More tests => 6;

use HTML::FormFu;
use lib 't/lib';
use DBICTestLib 'new_schema';
use MySchema;
my $form = HTML::FormFu->new;

$form->load_config_file('t/options_from_model/enum_select.yml');

my $schema = new_schema();

$form->stash->{schema} = $schema;

my $master_rs = $schema->resultset('Master');

$form->process;

{
    my $option = $form->get_field('enum_col')->options;

    is( scalar( @$option ), 3 );

    is( $option->[0]->{label}, 'a' );
    is( $option->[1]->{label}, 'b' );
    is( $option->[2]->{label}, 'c' );
}

# ensure the options are set in time for the AutoSet constraint to work

{
    $form->process({
        enum_col => 'a',
    });

    ok( $form->valid('enum_col') );
}

{
    $form->process({
        enum_col => 'd',
    });

    ok( ! $form->valid('enum_col') );
}