diff --git a/lib/WebGUI/Shop/ShipDriver.pm b/lib/WebGUI/Shop/ShipDriver.pm index f0fd09518..1b4cadc58 100644 --- a/lib/WebGUI/Shop/ShipDriver.pm +++ b/lib/WebGUI/Shop/ShipDriver.pm @@ -60,6 +60,19 @@ sub _buildObj { } +#------------------------------------------------------------------- + +=head2 calculate ( ) + +This method calculates how much it costs to ship the contents of a cart. This method +MUST be overridden in all child classes. + +=cut + +sub calculate { + croak "You must override the calculate method"; +} + #------------------------------------------------------------------- =head2 className ( ) diff --git a/t/Shop/ShipDriver.t b/t/Shop/ShipDriver.t index a7a0db5db..8cc66638c 100644 --- a/t/Shop/ShipDriver.t +++ b/t/Shop/ShipDriver.t @@ -31,7 +31,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 28; +my $tests = 29; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -238,6 +238,15 @@ is($driver->getId, $driverCopy->getId, 'same id'); is($driver->className, $driverCopy->className, 'same className'); cmp_deeply($driver->options, $driverCopy->options, 'same options'); +####################################################################### +# +# calculate +# +####################################################################### + +eval { $driver->calculate; }; +like ($@, qr/^You must override the calculate method/, 'calculate throws an exception to force overriding it in the child classes'); + ####################################################################### # # delete @@ -251,12 +260,6 @@ is($count, 0, 'delete deleted the object'); undef $driver; -####################################################################### -# -# calculate -# -####################################################################### - } #----------------------------------------------------------------------------