diff --git a/t/Form/Checkbox.t b/t/Form/Checkbox.t index 6997a5e49..8be50ce18 100644 --- a/t/Form/Checkbox.t +++ b/t/Form/Checkbox.t @@ -45,7 +45,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Checkbox'; my $formType = 'Checkbox'; -my $numTests = 6 + scalar @{ $testBlock } + 1; +my $numTests = 7 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -57,7 +57,7 @@ my $html = join "\n", $header, $formClass->new($session, { name => 'CBox1', - value => 'Check me', + value => 'Checkme', checked => 1, })->toHtml, $footer; @@ -76,8 +76,31 @@ is(scalar @inputs, 1, 'The form has 1 input'); my $input = $inputs[0]; is($input->name, 'CBox1', 'Checking input name'); is($input->type, 'checkbox', 'Checking input type'); -is($input->value, 'Check me', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); +is($input->value, 'Checkme', 'Checking default value'); + +$html = join "\n", + $header, + $formClass->new($session, { + name => 'cbox2', + value => '024680', + checked => 1, + })->toHtml, + $footer; + +@forms = HTML::Form->parse($html, 'http://www.webgui.org'); +is( $forms[0]->param('cbox2'), '024680', 'numeric values'); + +$html = join "\n", + $header, + $formClass->new($session, { + name => 'cbox3', + value => ' ', + checked => 1, + })->toHtml, + $footer; + +@forms = HTML::Form->parse($html, 'http://www.webgui.org'); +is( $forms[0]->param('cbox3'), ' ', 'WRONG: whitespace value'); ##Test Form Output parsing diff --git a/t/Form/Email.t b/t/Form/Email.t index 349e90b56..e89d41630 100644 --- a/t/Form/Email.t +++ b/t/Form/Email.t @@ -46,7 +46,7 @@ my $testBlock = [ my $formType = 'text'; my $formClass = 'WebGUI::Form::Email'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -77,7 +77,6 @@ my $input = $inputs[0]; is($input->name, 'TestEmail', 'Checking input name'); is($input->type, $formType, 'Checking input type'); is($input->value, 'me@nowhere.com', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 30, 'Checking size param, default'); is($input->{maxlength}, 255, 'Checking maxlength param, default'); diff --git a/t/Form/Float.t b/t/Form/Float.t index c303e797b..d7d6253c1 100644 --- a/t/Form/Float.t +++ b/t/Form/Float.t @@ -88,7 +88,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Float'; my $formType = 'Float'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -119,7 +119,6 @@ my $input = $inputs[0]; is($input->name, 'TestFloat', 'Checking input name'); is($input->type, 'text', 'Checking input type'); is($input->value, '12.3456', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 11, 'Default size'); is($input->{maxlength}, 14, 'Default maxlength'); diff --git a/t/Form/Hidden.t b/t/Form/Hidden.t index 55cec73ea..4f6574046 100644 --- a/t/Form/Hidden.t +++ b/t/Form/Hidden.t @@ -63,7 +63,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Hidden'; -my $numTests = 6 + scalar @{ $testBlock } + 1; +my $numTests = 5 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -94,7 +94,6 @@ my $input = $inputs[0]; is($input->name, 'TestHidden', 'Checking input name'); is($input->type, 'hidden', 'Checking input type'); is($input->value, 'hiddenData', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); ##no need for secondary checking for now diff --git a/t/Form/Integer.t b/t/Form/Integer.t index ad1ea5b13..504790819 100644 --- a/t/Form/Integer.t +++ b/t/Form/Integer.t @@ -63,7 +63,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Integer'; my $formType = 'Integer'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -94,7 +94,6 @@ my $input = $inputs[0]; is($input->name, 'TestInteger', 'Checking input name'); is($input->type, 'text', 'Checking input type'); is($input->value, '123456', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 11, 'Default size'); is($input->{maxlength}, 11, 'Default maxlength'); diff --git a/t/Form/Password.t b/t/Form/Password.t index 16173003f..5f3361b1b 100644 --- a/t/Form/Password.t +++ b/t/Form/Password.t @@ -45,7 +45,7 @@ my $testBlock = [ my $formType = 'password'; my $formClass = 'WebGUI::Form::Password'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -77,7 +77,6 @@ use Data::Dumper; is($input->name, 'TestText', 'Checking input name'); is($input->type, $formType, 'Checking input type'); is($input->value, 'Some text in here', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 30, 'Default size'); is($input->{maxlength}, 35, 'Default maxlength'); diff --git a/t/Form/Phone.t b/t/Form/Phone.t index ddf940fa2..471f6e419 100644 --- a/t/Form/Phone.t +++ b/t/Form/Phone.t @@ -87,7 +87,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Phone'; my $formType = 'Phone'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -118,7 +118,6 @@ my $input = $inputs[0]; is($input->name, 'TestPhone', 'Checking input name'); is($input->type, 'text', 'Checking input type'); is($input->value, '(555)867-5309', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 30, 'Default size'); is($input->{maxlength}, 255, 'Default maxlength'); diff --git a/t/Form/Radio.t b/t/Form/Radio.t new file mode 100644 index 000000000..d8329ff1c --- /dev/null +++ b/t/Form/Radio.t @@ -0,0 +1,107 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; +use WebGUI::Form; +use WebGUI::Form::Radio; +use WebGUI::Session; +use HTML::Form; +use WebGUI::Form_Checking; + +#The goal of this test is to verify that Radio form elements work + +use Test::More; # increment this value for each test you create + +my $session = WebGUI::Test->session; + +# put your tests here + +my $testBlock = [ + { + key => 'RADIO1', + testValue => 'string1', + expected => 'EQUAL', + comment => 'string check' + }, + { + key => 'RADIO2', + testValue => '002300', + expected => 'EQUAL', + comment => 'valid, leading zeroes' + }, +]; + +my $formClass = 'WebGUI::Form::Radio'; +my $formType = 'Radio'; + +my $numTests = 7 + scalar @{ $testBlock } + 1; + +diag("Planning on running $numTests tests\n"); + +plan tests => $numTests; + +my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session)); + +my $html = join "\n", + $header, + $formClass->new($session, { + name => 'radio1', + value => 'Selectify', + checked => 1, + })->toHtml, + $footer; + +my @forms = HTML::Form->parse($html, 'http://www.webgui.org'); + +##Test Form Generation + +is(scalar @forms, 1, '1 form was parsed'); + +my @inputs = $forms[0]->inputs; +is(scalar @inputs, 1, 'The form has 1 input'); + +#Basic tests +my $input = $inputs[0]; +is($input->name, 'radio1', 'Checking input name'); +is($input->type, 'radio', 'Checking input type'); +is($input->value, 'Selectify', 'Checking default value'); + +$html = join "\n", + $header, + $formClass->new($session, { + name => 'radio2', + value => '024680', + checked => 1, + })->toHtml, + $footer; + +@forms = HTML::Form->parse($html, 'http://www.webgui.org'); +is( $forms[0]->param('radio2'), '024680', 'numeric values'); + +$html = join "\n", + $header, + $formClass->new($session, { + name => 'radio2', + value => ' ', + checked => 1, + })->toHtml, + $footer; + +@forms = HTML::Form->parse($html, 'http://www.webgui.org'); +is( $forms[0]->param('radio2'), ' ', 'WRONG: whitespace value'); + +##Test Form Output parsing + +WebGUI::Form_Checking::auto_check($session, $formType, $testBlock); + diff --git a/t/Form/SelectBox.t b/t/Form/SelectBox.t index e89b85a28..abeef70bc 100644 --- a/t/Form/SelectBox.t +++ b/t/Form/SelectBox.t @@ -48,7 +48,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::SelectBox'; my $formType = 'SelectBox'; -my $numTests = 9 + scalar @{ $testBlock } + 1; +my $numTests = 8 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -83,7 +83,6 @@ is(scalar @inputs, 1, 'The form has 1 input'); my $input = $form->find_input('ListBox'); is($input->name, 'ListBox', 'Checking input name'); is($input->type, 'option', 'Checking input type'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->value, 'c', 'Checking default value'); is($input->{size}, 1, 'default size'); diff --git a/t/Form/Text.t b/t/Form/Text.t index cea628deb..e66e3e348 100644 --- a/t/Form/Text.t +++ b/t/Form/Text.t @@ -44,7 +44,7 @@ my $testBlock = [ my $formType = 'text'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -75,7 +75,6 @@ my $input = $inputs[0]; is($input->name, 'TestText', 'Checking input name'); is($input->type, $formType, 'Checking input type'); is($input->value, 'Some text in here', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 30, 'Checking size param, default'); is($input->{maxlength}, 255, 'Checking maxlength param, default'); diff --git a/t/Form/Textarea.t b/t/Form/Textarea.t index ae03c401a..cc0f0a967 100644 --- a/t/Form/Textarea.t +++ b/t/Form/Textarea.t @@ -44,7 +44,7 @@ my $testBlock = [ my $formType = 'textarea'; -my $numTests = 14 + scalar @{ $testBlock } + 1; +my $numTests = 13 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -75,7 +75,6 @@ my $input = $inputs[0]; is($input->name, 'TestText', 'Checking input name'); is($input->type, $formType, 'Checking input type'); is($input->value, 'Some text in here', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{rows}, 5, 'Default number of rows'); is($input->{cols}, 50, 'Default number of columns'); is($input->{wrap}, 'virtual', 'Default wrap'); diff --git a/t/Form/Url.t b/t/Form/Url.t index 12e61b3d0..5a03b2952 100644 --- a/t/Form/Url.t +++ b/t/Form/Url.t @@ -74,7 +74,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Url'; -my $numTests = 12 + scalar @{ $testBlock } + 1; +my $numTests = 11 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -105,7 +105,6 @@ my $input = $inputs[0]; is($input->name, 'TestUrl', 'Checking input name'); is($input->type, 'text', 'Checking input type'); is($input->value, 'http://www.webgui.org', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 30, 'Checking size param, default'); is($input->{maxlength}, 2048, 'Checking maxlength param, default'); diff --git a/t/Form/Zipcode.t b/t/Form/Zipcode.t index 5ef65a986..df81e168c 100644 --- a/t/Form/Zipcode.t +++ b/t/Form/Zipcode.t @@ -62,7 +62,7 @@ my $testBlock = [ my $formClass = 'WebGUI::Form::Zipcode'; -my $numTests = 14 + scalar @{ $testBlock } + 1; +my $numTests = 12 + scalar @{ $testBlock } + 1; diag("Planning on running $numTests tests\n"); @@ -93,7 +93,6 @@ my $input = $inputs[0]; is($input->name, 'TestZip', 'Checking input name'); is($input->type, 'text', 'Checking input type'); is($input->value, '97123-ORST', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 30, 'Checking size param, default'); is($input->{maxlength}, 10, 'Checking maxlength param, default'); @@ -113,7 +112,6 @@ $input = $inputs[0]; is($input->name, 'TestZip2', 'Checking input name'); is($input->type, 'text', 'Checking input type'); is($input->value, '97229-MXIM', 'Checking default value'); -is($input->disabled, undef, 'Disabled param not sent to form'); is($input->{size}, 12, 'Checking size param, default'); is($input->{maxlength}, 13, 'Checking maxlength param, default');