File: default_args_not_inheriting.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 (37 lines) | stat: -rw-r--r-- 937 bytes parent folder | download | duplicates (2)
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 tests => 3;

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'    => { auto_id    => 'ID' },
            SimpleTable => { attributes => { class => 'custom class' } },
        },
    } );

# 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 => 'SimpleTable',
                name => 'foo',
            },
        ],
    } );

my $table = $form->get_all_element({ type => 'SimpleTable' });

like( $table, qr/table [^>]*class="[^"]*custom class[^"]*"/ );

is( $table->auto_id, undef );

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