File: required_only_on_reps.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 (86 lines) | stat: -rw-r--r-- 1,696 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use strict;
use warnings;

use Test::More tests => 4;

use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;

my $form = HTML::FormFu->new;

$form->load_config_file('t-aggregate/constraints/required_only_on_reps.yml');

# Valid
{
    $form->process( {
            foo_1 => 'a',
            bar_1 => '',
            buz_1 => 'g',
            moo_1 => 'j',
            foo_2 => '',
            bar_2 => 'e',
            buz_2 => '',
            moo_2 => 'k',
            foo_3 => '',
            bar_3 => '',
            buz_3 => 'i',
            moo_3 => 'l',
            count => 3,
        } );

    ok( $form->submitted_and_valid );
}

# Valid
{
    $form->process( {
            foo_1 => 'a',
            bar_1 => 'd',
            buz_1 => 'g',
            moo_1 => 'j',
            foo_2 => 'b',
            bar_2 => 'e',
            buz_2 => 'h',
            moo_2 => 'k',
            foo_3 => 'c',
            bar_3 => 'f',
            buz_3 => 'i',
            moo_3 => 'l',
            count => 3,
        } );

    ok( $form->submitted_and_valid );
}

# Missing - Invalid
{
    $form->process( {
            foo_1 => '',
            bar_1 => '',
            buz_1 => '',
            moo_1 => '',
            foo_2 => '',
            bar_2 => '',
            buz_2 => '',
            moo_2 => 'k',
            foo_3 => '',
            bar_3 => '',
            buz_3 => 'i',
            moo_3 => '',
            count => 3,
        } );

    ok( !$form->submitted_and_valid );

    is_deeply(
        [ $form->has_errors ],
        [   qw/
                foo_1
                buz_1
                moo_1
                bar_2
                moo_3
                /
        ] );
}