File: constraints_from_dbic_rs.t

package info (click to toggle)
libhtml-formfu-perl 0.09007-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,184 kB
  • sloc: perl: 13,186; makefile: 9; sql: 5
file content (30 lines) | stat: -rw-r--r-- 674 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings;

our $count;
BEGIN { $count = 3 }
use Test::More tests => $count;

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

SKIP: {
    eval "use MyApp::Schema";

    skip 'DBIx::Class needed', $count if $@;

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

    $form->element( { name => 'title' } );
    $form->element( { name => 'name' } );
    $form->element( { name => 'age' } );

    my $schema = MyApp::Schema->connect;

    $form->constraints_from_dbic( $schema->resultset('Person') );

    is( @{ $form->get_field('title')->get_constraints }, 1 );
    is( @{ $form->get_field('name')->get_constraints },  1 );
    is( @{ $form->get_field('age')->get_constraints },   2 );

}