File: checkbox.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 (37 lines) | stat: -rw-r--r-- 867 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
use strict;
use warnings;
use Test::More;
use HTML::FormHandler::Test;
use Test::Exception;

{
    package MyApp::Form::Field::EmailOptin;
    use HTML::FormHandler::Moose;
    extends 'HTML::FormHandler::Field::Checkbox';

    sub build_label { 'Send me expert college planning tips and advice.' }
    has '+default'    => (default => 1,);
    sub build_wrapper_class { ['email-optin'] }
}

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

    has '+field_name_space' => ( default => sub { ['MyApp::Form::Field'] } );

    has_field 'foo' => (
        type => 'EmailOptin',
        option_wrapper => 'nonexistent',
    );
    has_field 'bar' => (
    );
}

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

dies_ok( sub { $form->render }, 'form dies with error about option_wrapper' );

done_testing;