File: default_args_isa.t

package info (click to toggle)
libhtml-formfu-perl 0.07002-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,928 kB
  • ctags: 989
  • sloc: perl: 12,036; makefile: 9; sql: 5
file content (41 lines) | stat: -rw-r--r-- 992 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
use strict;
use warnings;

use Test::More tests => 4;

use HTML::FormFu;
use Storable qw( dclone );

my $form = HTML::FormFu->new({ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } });

$form->default_args( {
        elements => {
            Block  => { attributes => { class => 'block' } },
            Multi  => { label      => 'My Label' },
            _Field => { comment    => 'My Comment' },
        },
    } );

# take a deep copy of element_defaults, so we can check they've not been butchered, later

my $default_args = dclone( $form->default_args );

$form->populate( {
        elements => [
            {   type => 'Multi',
                name => 'foo',
            },
        ],
    } );

my $multi = $form->get_all_element({ type => 'Multi' });

like( $multi, qr/class="[^"]*block[^"]*"/ );

is( $multi->label, 'My Label' );

is( $multi->comment, 'My Comment' );


# original default_args hashref hasn't been butchered
is_deeply( $default_args, $form->default_args );