add Tests for getShippers, and some code for the method too.

This commit is contained in:
Colin Kuskie 2008-02-29 00:36:39 +00:00
parent df47d0a07c
commit 1261c96349
2 changed files with 43 additions and 12 deletions

View file

@ -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

View file

@ -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();
}
#----------------------------------------------------------------------------