/t/list.t
text | 39 lines | 27 code | 12 blank | 0 comment | 0 complexity | 50e2236bbe51b30d77b3c3afed103b93 MD5 | raw file
1use strict; 2use warnings; 3use Test::More; 4 5use_ok('HTML::FormHandler::Field::Repeatable'); 6 7{ 8 package List::Form; 9 use HTML::FormHandler::Moose; 10 extends 'HTML::FormHandler'; 11 12 has_field 'tags' => ( type => 'Repeatable' ); 13 has_field 'tags.contains'; 14 15} 16 17my $form = List::Form->new; 18 19ok( $form, 'form created' ); 20 21my $params = { 22 tags => ['linux', 'algorithms', 'loops'], 23}; 24$form->process($params); 25 26ok( $form->validated, 'form validated' ); 27 28is( $form->field('tags')->field('0')->value, 'linux', 'get correct value' ); 29 30my $fif = { 31 'tags.0' => 'linux', 32 'tags.1' => 'algorithms', 33 'tags.2' => 'loops', 34}; 35is_deeply( $form->fif, $fif, 'fif is correct' ); 36 37is_deeply( $form->values, $params, 'values are correct' ); 38 39done_testing;