fix test
This commit is contained in:
parent
392bb0306f
commit
fab0e078f5
1 changed files with 2 additions and 35 deletions
|
|
@ -18,6 +18,7 @@ use WebGUI::Macro::FormParam;
|
|||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::MockObject;
|
||||
use WebGUI::Form_Checking;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ $numTests += 3; ##TODO block
|
|||
|
||||
plan tests => $numTests;
|
||||
|
||||
auto_check($session, \@testSets);
|
||||
WebGUI::Form_Checking::auto_check($session, \@testSets);
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to write later";
|
||||
|
|
@ -68,37 +69,3 @@ TODO: {
|
|||
ok(0, "Also try undef");
|
||||
}
|
||||
|
||||
sub auto_check {
|
||||
my ($session, $testBlock) = @_;
|
||||
my $origSessionRequest = $session->{_request};
|
||||
|
||||
##Create a by-name interface to the test to simplify the
|
||||
##mocked request.
|
||||
my %tests = map { $_->{key} => $_ } @{ $testBlock };
|
||||
is(scalar keys %tests, scalar @{ $testBlock }, 'no collisions in testBlock');
|
||||
|
||||
my $request = Test::MockObject->new;
|
||||
$request->mock('body',
|
||||
sub {
|
||||
my ($self, $value) = @_;
|
||||
return unless exists $tests{$value};
|
||||
if (ref $tests{$value}->{testValue} eq "ARRAY") {
|
||||
return @{ $tests{$value}->{testValue} } ;
|
||||
}
|
||||
else {
|
||||
return $tests{$value}->{testValue};
|
||||
}
|
||||
}
|
||||
);
|
||||
$request->mock('param', sub {shift->body(@_)});
|
||||
|
||||
$session->{_request} = $request;
|
||||
|
||||
foreach my $test ( @{ $testBlock } ) {
|
||||
$test->{expected} = $test->{testValue} if $test->{expected} eq 'EQUAL';
|
||||
my $value = WebGUI::Macro::FormParam::process($session, $test->{key});
|
||||
is($value, $test->{expected}, $test->{comment});
|
||||
}
|
||||
|
||||
$session->{_request} = $origSessionRequest;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue