Cleaned the pollution from the forms system.

This commit is contained in:
JT Smith 2008-04-16 16:11:10 +00:00
parent 53b81b36d0
commit 8500c4d506
81 changed files with 2675 additions and 1570 deletions

View file

@ -108,5 +108,5 @@ WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
#
# test WebGUI::FormValidator::Checkbox(undef,@values)
#
is(WebGUI::Form::Checkbox->new($session)->getValueFromPost('test'), 'test', '$cbox->getValueFromPost(arg)');
is(WebGUI::Form::Checkbox->new($session)->getValue('test'), 'test', '$cbox->getValue(arg)');
is($session->form->checkbox(undef,'test'), 'test', 'WebGUI::FormValidator::checkbox');

View file

@ -130,5 +130,5 @@ WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
#
# test WebGUI::FormValidator::ClassName(undef,@values)
#
is(WebGUI::Form::ClassName->new($session)->getValueFromPost('t*est'), 'test', '$cname->getValueFromPost(arg)');
is(WebGUI::Form::ClassName->new($session)->getValue('t*est'), 'test', '$cname->getValue(arg)');
is($session->form->className(undef,'t*est'), 'test', 'WebGUI::FormValidator::className');

View file

@ -107,11 +107,11 @@ is($input->{maxlength}, 200, 'Checking maxlength param, set');
WebGUI::Form_Checking::auto_check($session, 'email', $testBlock);
# just testing that getValueFromPost works with an argument
# just testing that getValue works with an argument
my $email = WebGUI::Form::Email->new($session);
is($email->getValueFromPost('james@plainblack.com'), 'james@plainblack.com', 'getValueFromPost(valid) returned a valid email');
is($email->getValueFromPost('this*isn"t and@emailaddres,s'), undef, 'getValueFromPost(invalid) returned undef instead of an invalid email');
is($email->getValue('james@plainblack.com'), 'james@plainblack.com', 'getValue(valid) returned a valid email');
is($email->getValue('this*isn"t and@emailaddres,s'), undef, 'getValue(invalid) returned undef instead of an invalid email');
is($session->form->email(undef,'james@plainblack.com'), 'james@plainblack.com', '$form->email(valid) returned a valid email');
is($session->form->email(undef,'this*isn"t and@emailaddres,s'), undef, '$form->email(invalid) returned undef instead of an invalid email');

View file

@ -143,11 +143,11 @@ is($input->{maxlength}, 20, 'set maxlength');
WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
# just testing that getValueFromPost works with an argument
# just testing that getValue works with an argument
my $float = WebGUI::Form::Float->new($session);
is($float->getValueFromPost('112.233'), 112.233, 'Got a valid float');
is($float->getValueFromPost('fred'), 0, 'Returned 0 instead of an invalid float');
is($float->getValue('112.233'), 112.233, 'Got a valid float');
is($float->getValue('fred'), 0, 'Returned 0 instead of an invalid float');
__END__

View file

@ -120,14 +120,14 @@ is($input->{maxlength}, 20, 'set maxlength');
WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
# just testing that getValueFromPost works with an argument
# just testing that getValue works with an argument
my $int = WebGUI::Form::Integer->new($session);
is($int->getValueFromPost(-123456), -123456, 'getValueFromPost(-123456)');
is($int->getValueFromPost('002300'), '002300', 'getValueFromPost(002300)');
is($int->getValueFromPost('+123456'), 0, 'getValueFromPost(+123456)');
is($int->getValueFromPost('123-456.'), 0, 'getValueFromPost(123-456.)');
is($int->getValueFromPost(123.456), 0, 'getValueFromPost(123.456)');
is($int->getValue(-123456), -123456, 'getValue(-123456)');
is($int->getValue('002300'), '002300', 'getValue(002300)');
is($int->getValue('+123456'), 0, 'getValue(+123456)');
is($int->getValue('123-456.'), 0, 'getValue(123-456.)');
is($int->getValue(123.456), 0, 'getValue(123.456)');
is($session->form->integer(undef,-123456), -123456, 'session->form->integer(undef,-123456)');
is($session->form->integer(undef,'002300'), '002300', 'session->form->integer(undef,002300)');

View file

@ -146,10 +146,10 @@ WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
# test that we can process non-POST values correctly
my $cntl = WebGUI::Form::Phone->new($session,{ defaultValue => 4242 });
is($cntl->getValueFromPost('123-123-1234'), '123-123-1234', 'getValueFromPost(valid)');
is($cntl->getValueFromPost('123/123-1234'), undef, 'getValueFromPost(invalid)');
is($cntl->getValueFromPost(0), 0, 'zero');
is($cntl->getValueFromPost(''), undef, '""');
is($cntl->getValue('123-123-1234'), '123-123-1234', 'getValue(valid)');
is($cntl->getValue('123/123-1234'), undef, 'getValue(invalid)');
is($cntl->getValue(0), 0, 'zero');
is($cntl->getValue(''), undef, '""');
is($session->form->phone(undef,'123-123-1234'), '123-123-1234', 'valid');
is($session->form->phone(undef,'123/123-1234'), undef, 'invalid');
is($session->form->phone(undef,0), 0, 'zero');

View file

@ -110,11 +110,11 @@ WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
# test that we can process non-POST values correctly
my $cntl = WebGUI::Form::SelectBox->new($session,{ defaultValue => 4242 });
is($cntl->getValueFromPost('text'), 'text', 'getValueFromPost(text)');
is($cntl->getValueFromPost(42), 42, 'getValueFromPost(int)');
is($cntl->getValueFromPost(0), 0, 'zero');
is($cntl->getValueFromPost(''), '', '""');
is($cntl->getValueFromPost(1,2,3), 1, 'list returns first item');
is($cntl->getValue('text'), 'text', 'getValue(text)');
is($cntl->getValue(42), 42, 'getValue(int)');
is($cntl->getValue(0), 0, 'zero');
is($cntl->getValue(''), '', '""');
is($cntl->getValue(1,2,3), 1, 'list returns first item');
is($session->form->selectBox(undef,'text'), 'text', 'text');
is($session->form->selectBox(undef,42), 42, 'int');
is($session->form->selectBox(undef,0), 0, 'zero');

View file

@ -116,10 +116,10 @@ WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
# test that we can process non-POST values correctly
my $cntl = WebGUI::Form::Text->new($session,{ defaultValue => 4242 });
is($cntl->getValueFromPost('123-123-1234'), '123-123-1234', 'getValueFromPost(valid)');
is($cntl->getValueFromPost(0), 0, 'zero');
is($cntl->getValueFromPost(''), '', '""');
is($cntl->getValueFromPost(undef), undef, 'undef returns undef');
is($cntl->getValue('123-123-1234'), '123-123-1234', 'getValue(valid)');
is($cntl->getValue(0), 0, 'zero');
is($cntl->getValue(''), '', '""');
is($cntl->getValue(undef), undef, 'undef returns undef');
is($session->form->text(undef,'123-123-1234'), '123-123-1234', 'valid');
is($session->form->text(undef,0), 0, 'zero');
is($session->form->text(undef,undef), undef, 'undef returns undef');

View file

@ -95,11 +95,11 @@ is($input->value, 'Some & text in " here', 'Checking default value');
WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
# just testing that getValueFromPost works with an argument
# just testing that getValue works with an argument
my $txt = WebGUI::Form::Textarea->new($session);
is($txt->getValueFromPost("some test here"), "some test here", 'getValueFromPost(text)');
is($txt->getValueFromPost("some \ntest \r\nhere"), "some \ntest \r\nhere", 'getValueFromPost(newlines)');
is($txt->getValue("some test here"), "some test here", 'getValue(text)');
is($txt->getValue("some \ntest \r\nhere"), "some \ntest \r\nhere", 'getValue(newlines)');
is($session->form->textarea(undef,"some test here"), "some test here", 'session->form->textarea(undef,text)');
is($session->form->textarea(undef,"some \ntest \r\nhere"), "some \ntest \r\nhere", 'session->form->textarea(undef,newlines)');

View file

@ -134,13 +134,13 @@ WebGUI::Form_Checking::auto_check($session, 'Url', $testBlock);
# test that we can process non-POST values correctly
my $cntl = WebGUI::Form::Url->new($session,{ defaultValue => 4242 });
is($cntl->getValueFromPost('mailto:whatever'), 'mailto:whatever', 'mailto processing');
is($cntl->getValueFromPost('me@nowhere.com'), 'mailto:me@nowhere.com', 'email address processing');
is($cntl->getValueFromPost('/'), '/', '/');
is($cntl->getValueFromPost('://'), '://', '://');
is($cntl->getValueFromPost('^'), '^', '^');
is($cntl->getValueFromPost('mySite'), 'http://mySite', 'http://mySite');
is($cntl->getValueFromPost('??**()!!'), 'http://??**()!!', 'random crap is passed through');
is($cntl->getValue('mailto:whatever'), 'mailto:whatever', 'mailto processing');
is($cntl->getValue('me@nowhere.com'), 'mailto:me@nowhere.com', 'email address processing');
is($cntl->getValue('/'), '/', '/');
is($cntl->getValue('://'), '://', '://');
is($cntl->getValue('^'), '^', '^');
is($cntl->getValue('mySite'), 'http://mySite', 'http://mySite');
is($cntl->getValue('??**()!!'), 'http://??**()!!', 'random crap is passed through');
is($session->form->url(undef,'mailto:whatever'), 'mailto:whatever', 'mailto processing');
is($session->form->url(undef,'me@nowhere.com'), 'mailto:me@nowhere.com', 'email address processing');

View file

@ -120,11 +120,11 @@ WebGUI::Form_Checking::auto_check($session, 'Zipcode', $testBlock);
# test that we can process non-POST values correctly
my $cntl = WebGUI::Form::Zipcode->new($session,{ defaultValue => 4242 });
is($cntl->getValueFromPost('ABCDE'), 'ABCDE', 'alpha');
is($cntl->getValueFromPost('02468'), '02468', 'numeric');
is($cntl->getValueFromPost('NO WHERE'), 'NO WHERE', 'alpha space');
is($cntl->getValueFromPost('-'), '-', 'bare dash');
is($cntl->getValueFromPost('abcde'), undef, 'lower case');
is($cntl->getValue('ABCDE'), 'ABCDE', 'alpha');
is($cntl->getValue('02468'), '02468', 'numeric');
is($cntl->getValue('NO WHERE'), 'NO WHERE', 'alpha space');
is($cntl->getValue('-'), '-', 'bare dash');
is($cntl->getValue('abcde'), undef, 'lower case');
is($session->form->zipcode(undef,'ABCDE'), 'ABCDE', 'alpha');
is($session->form->zipcode(undef,'02468'), '02468', 'numeric');