Add input validation for the add method, and test it.

Now it's time for the import and export methods.
This commit is contained in:
Colin Kuskie 2008-02-16 06:48:00 +00:00
parent 645c21bc3b
commit 0701adf7e0
2 changed files with 49 additions and 2 deletions

View file

@ -28,7 +28,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 17;
my $tests = 24;
plan tests => 1 + $tests;
#----------------------------------------------------------------------------
@ -72,6 +72,46 @@ is($taxIterator->rows, 0, 'WebGUI ships with no predefined tax data');
#
#######################################################################
eval{$taxer->add()};
like($@, qr{Must pass in a hashref},
'add: error handling for missing hashref');
eval{$taxer->add({})};
like($@, qr{Hash ref must contain a field key with a defined value},
'add: error handling for missing field hashref key');
my $taxData = {
field => undef,
};
eval{$taxer->add($taxData)};
like($@, qr{Hash ref must contain a field key with a defined value},
'add: error handling for undefined field key');
$taxData->{field} = 'state';
eval{$taxer->add($taxData)};
like($@, qr{Hash ref must contain a value key with a defined value},
'add: error handling for missing value key');
$taxData->{value} = undef;
eval{$taxer->add($taxData)};
like($@, qr{Hash ref must contain a value key with a defined value},
'add: error handling for undefined value key');
$taxData->{value} = 'Oregon';
eval{$taxer->add($taxData)};
like($@, qr{Hash ref must contain a taxRate key with a defined value},
'add: error handling for missing taxRate key');
$taxData->{taxRate} = undef;
eval{$taxer->add($taxData)};
like($@, qr{Hash ref must contain a taxRate key with a defined value},
'add: error handling for undefined taxRate key');
my $taxData = {
field => 'state',
value => 'Oregon',