add post processing tests
This commit is contained in:
parent
5c46fc7f56
commit
be57f039b0
1 changed files with 23 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ use WebGUI::Test;
|
|||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Session;
|
||||
use HTML::Form;
|
||||
use Data::Dumper;
|
||||
use Test::MockObject;
|
||||
|
||||
#The goal of this test is to verify that Text form elements
|
||||
#work, via HTMLForm.
|
||||
|
|
@ -29,7 +29,7 @@ my $i18n = WebGUI::International->new($session);
|
|||
|
||||
# put your tests here
|
||||
|
||||
my $numTests = 6;
|
||||
my $numTests = 8;
|
||||
|
||||
diag("Planning on running $numTests tests\n");
|
||||
|
||||
|
|
@ -46,6 +46,8 @@ my $html = $HTMLForm->print;
|
|||
|
||||
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;
|
||||
|
|
@ -56,3 +58,22 @@ is($input->name, 'TestText', 'Checking input name');
|
|||
is($input->type, 'text', 'Checking input type');
|
||||
is($input->value, 'Some text in here', 'Checking default value');
|
||||
is($input->disabled, undef, 'Disabled param not sent to form');
|
||||
|
||||
##Test Form Output parsing
|
||||
|
||||
my $request = Test::MockObject->new;
|
||||
$request->mock('body',
|
||||
sub {
|
||||
my ($self, $value) = @_;
|
||||
my @return = ();
|
||||
return 'some user value' if ($value eq 'TestText');
|
||||
return "some user value\nwith\r\nwhitespace" if ($value eq 'TestText2');
|
||||
return;
|
||||
}
|
||||
);
|
||||
$session->{_request} = $request;
|
||||
|
||||
my $value = $session->form->get('TestText', 'Text');
|
||||
is($value, 'some user value', 'checking existent form value');
|
||||
$value = $session->form->get('TestText2', 'Text');
|
||||
is($value, 'some user valuewithwhitespace', 'checking form postprocessing for whitespace');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue