Finalize getShippers, along with tests.
This commit is contained in:
parent
1261c96349
commit
d780700013
2 changed files with 20 additions and 2 deletions
|
|
@ -127,6 +127,14 @@ sub getShippers {
|
|||
my $session = shift;
|
||||
WebGUI::Error::InvalidParam->throw(error => q{Must provide a session variable})
|
||||
unless ref $session eq 'WebGUI::Session';
|
||||
my $drivers;
|
||||
my $sth = $session->db->prepare('select shipperId from shipper');
|
||||
$sth->execute();
|
||||
while (my $driver = $sth->hashRef()) {
|
||||
push @{ $drivers }, WebGUI::Shop::Ship->new($session, $driver->{shipperId});
|
||||
}
|
||||
$sth->finish;
|
||||
return $drivers;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
my $tests = 25;
|
||||
my $tests = 27;
|
||||
plan tests => 1 + $tests;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -195,6 +195,7 @@ cmp_deeply($driverCopy->options, $driver->options, 'same options');
|
|||
#######################################################################
|
||||
|
||||
my $shippers;
|
||||
my $driver2 = WebGUI::Shop::Ship->create($session, 'WebGUI::Shop::ShipDriver::FlatRate', { enabled=>1, label=>q{Tommy's cut-rate shipping}});
|
||||
|
||||
eval { $shippers = WebGUI::Shop::Ship->getShippers(); };
|
||||
$e = Exception::Class->caught();
|
||||
|
|
@ -207,7 +208,16 @@ cmp_deeply(
|
|||
'getShippers takes exception to not giving it a session object',
|
||||
);
|
||||
|
||||
$shippers = WebGUI::Shop::Ship->getShippers();
|
||||
|
||||
$shippers = WebGUI::Shop::Ship->getShippers($session);
|
||||
is(scalar @{$shippers}, 2, 'getShippers: got both shippers');
|
||||
|
||||
my @shipperNames = map { $_->options()->{label} } @{ $shippers };
|
||||
cmp_bag(
|
||||
\@shipperNames,
|
||||
[q{Jake's Jailbird Airmail},q{Tommy's cut-rate shipping}],
|
||||
'Returned shippers have the right data'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue