X-Git-Url: http://git.shiar.nl/perl/html-form-simple.git/blobdiff_plain/61dd576040bbb86eb8925c1c80a830bfa998eb41..47c6a0e47426e447523d4697b2fb596366f7f9d4:/t/html.t diff --git a/t/html.t b/t/html.t index 89f82a1..08f0e6b 100644 --- a/t/html.t +++ b/t/html.t @@ -5,13 +5,39 @@ use warnings; use Test::More; -plan tests => 65; +plan tests => 80; use_ok('HTML::Form::Simple'); my $form = HTML::Form::Simple->new; ok($form, 'new form'); +# basics + +is( + $form->quote('<"test">'), + '<"test">', + 'quote' +); + +is( + $form->quote(\'<"test">'), + '<"test">', + 'quote unquoted' +); + +is( + $form->tag('foo'), + '', + 'tag' +); + +is( + $form->tag('a "' => {'b"' => 'c"'}), + '', + 'tag attributes' +); + # form is( @@ -312,14 +338,14 @@ is_deeply( is( $form->radio(foo => 'test'), - '', + '', 'radio method' ); is( - $form->radio(foo => undef, 2), - '', - 'labelless radio' + $form->radio(foo => undef, 'test'), + '', + 'labeled radio' ); is( @@ -330,15 +356,33 @@ is( is_deeply( [ $form->radio(undef, ['', '<">']) ], + [ + '', + '', + ], + 'multiple radios' +); + +is_deeply( + [ $form->radio(undef, undef, ['', '<">']) ], [ '', '', ], - 'multiple radios' + 'multiple radio labels' +); + +is_deeply( + [ $form->radio(undef, [0, 1], undef, 0) ], + [ + '', + '', + ], + 'radio default' ); is_deeply( - [ $form->radio(foo => 'test', ['foo', ''], {value => '', id => ''}) ], + [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ], [ '', '', @@ -347,7 +391,7 @@ is_deeply( ); is_deeply( - [ $form->radio(foo => ['', 0], [0, 1, '']) ], + [ $form->radio(foo => [0, 1, ''], ['', 0]) ], [ '', '', @@ -358,8 +402,8 @@ is_deeply( { # make sure arguments aren't modified - my @args = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1}); - my @orgs = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1}); + my @args = (foo => [0, {value => 1}], [0, 1], {name => 0, value => 1}); + my @orgs = (foo => [0, {value => 1}], [0, 1], {name => 0, value => 1}); my @output = ( '', '', @@ -375,7 +419,7 @@ is_deeply( [ $form->check(@args) ], [ '', - '', + '', ], 'options var to check' ); @@ -393,13 +437,13 @@ is_deeply( is( $form->check('foo'), - '', + '', 'check method' ); is( $form->check(foo => '<">'), - '', + '', 'labeled checkbox' ); @@ -415,13 +459,57 @@ is_deeply( 'anonymous checkbox' ); +is( + $form->check(foo => [undef]), + '', + 'multipart check' +); + +is_deeply( + [ $form->check(foo => [{value => undef}, undef]) ], + [ + '', + '', + ], + 'multiple checkboxes' +); + +is( + $form->check(foo => [undef], {id => ''}), + '', + 'idless checks' +); + +is_deeply( + [ $form->check( + foo => [ {id => 'quux'}, {name => 'name'}, {value => 0}, {id => ''}, undef ], {id => 'bar'} + ) ], + [ + '', + '', + '', + '', + '', + ], + 'check overrides' +); + +is_deeply( + [ $form->check(foo => ['bar', {name => 'bar'}], {name => 'ignored'}) ], + [ + '', + '', + ], + 'checkbox names' +); + is_deeply( [ $form->check(undef, ['', '<">']) ], [ '', '', ], - 'multiple checkboxes' + 'anonymous checkboxes' ); is_deeply( @@ -455,6 +543,32 @@ is_deeply( 'various checkboxes' ); +# row + +is( + $form->row(undef), + ' ', + 'empty row' +); + +is( + $form->row('test'), + ' ', + 'standard row' +); + +is( + $form->row('test', {type => 'password'}, {for => '', label => '"blah"'}), + ' ', + 'row options' +); + +is( + $form->row('test', '"scalar"', {for => ''}), + ' "scalar"', + 'row scalar' +); + # defaults my $defform = HTML::Form::Simple->new({foo => '<">', '' => 'empty', 0 => 0}); @@ -485,7 +599,7 @@ is( ); is_deeply( - [ $defform->radio(0 => undef, [1, 0]) ], + [ $defform->radio(0 => [1, 0]) ], [ '', '',