diff --git a/lib/WebGUI/Shop/Ship.pm b/lib/WebGUI/Shop/Ship.pm index d590ef728..a9fc76743 100644 --- a/lib/WebGUI/Shop/Ship.pm +++ b/lib/WebGUI/Shop/Ship.pm @@ -29,17 +29,6 @@ These subroutines are available from this package: #------------------------------------------------------------------- -=head2 _loadDriver ( ) - -The method used to safely load the Shipping drivers. - -=cut - -sub _loadDriver { -} - -#------------------------------------------------------------------- - =head2 create ( $session, $class, $options ) The interface method for creating new, configured instances of ShipDriver. If the ShipperDriver throws an exception, it is propagated @@ -121,6 +110,27 @@ sub getOptions { #------------------------------------------------------------------- +=head2 getShippers ( $session ) + +Returns an array ref of all shipping objects in the db. + +=head3 $session + +A WebGUI::Session object. A WebGUI::Error::InvalidParam exception will be thrown if it doesn't get one. + +=head3 + +=cut + +sub getShippers { + my $class = shift; + my $session = shift; + WebGUI::Error::InvalidParam->throw(error => q{Must provide a session variable}) + unless ref $session eq 'WebGUI::Session'; +} + +#------------------------------------------------------------------- + =head2 new ( $session, $shipperId ) Looks up an existing ShipperDriver in the db by shipperId and returns diff --git a/t/Shop/Ship.t b/t/Shop/Ship.t index 954732286..02cf18f7d 100644 --- a/t/Shop/Ship.t +++ b/t/Shop/Ship.t @@ -31,7 +31,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 23; +my $tests = 25; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -188,6 +188,27 @@ is($driverCopy->getId, $driver->getId, 'same id'); is($driverCopy->className, $driver->className, 'same className'); cmp_deeply($driverCopy->options, $driver->options, 'same options'); +####################################################################### +# +# getShippers +# +####################################################################### + +my $shippers; + +eval { $shippers = WebGUI::Shop::Ship->getShippers(); }; +$e = Exception::Class->caught(); +isa_ok($e, 'WebGUI::Error::InvalidParam', 'getShippers takes exception to not giving it a session object'); +cmp_deeply( + $e, + methods( + error => 'Must provide a session variable', + ), + 'getShippers takes exception to not giving it a session object', +); + +$shippers = WebGUI::Shop::Ship->getShippers(); + } #----------------------------------------------------------------------------