add a input validation check and test for Tax->calculate
This commit is contained in:
parent
9d377193d3
commit
5946fd5476
2 changed files with 15 additions and 9 deletions
|
|
@ -87,10 +87,9 @@ Calculate the tax for the contents of the cart.
|
|||
sub calculate {
|
||||
my $self = shift;
|
||||
my $cart = shift;
|
||||
|
||||
WebGUI::Error::InvalidParam->throw(error => 'Must pass in a WebGUI::Shop::Cart object')
|
||||
unless ref($cart) eq 'WebGUI::Shop::Cart';
|
||||
return $id;
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
21
t/Shop/Tax.t
21
t/Shop/Tax.t
|
|
@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
my $tests = 62;
|
||||
my $tests = 64;
|
||||
plan tests => 1 + $tests;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -366,6 +366,19 @@ cmp_deeply(
|
|||
'importTaxData: error handling for file that that cannot be read',
|
||||
);
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# calculate
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
eval { $taxer->calculate(); };
|
||||
$e = Exception::Class->caught();
|
||||
isa_ok($e, 'WebGUI::Error::InvalidParam', 'calculate: error handling for not sending a cart');
|
||||
is($e->error, 'Must pass in a WebGUI::Shop::Cart object', 'calculate: error handling for not sending a cart');
|
||||
|
||||
##Build a cart, add some Donation SKUs to it. Set one to be taxable.
|
||||
|
||||
}
|
||||
|
||||
sub _grabTaxData {
|
||||
|
|
@ -378,12 +391,6 @@ sub _grabTaxData {
|
|||
return @taxData;
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# calculate
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue