Add coverage tests, convert croaks to exceptions.
This commit is contained in:
parent
cd55ff1a9e
commit
d27ac7a629
4 changed files with 55 additions and 10 deletions
|
|
@ -2,7 +2,6 @@ package WebGUI::Shop::Ship;
|
|||
|
||||
use strict;
|
||||
|
||||
use Carp qw(croak);
|
||||
use WebGUI::International;
|
||||
use WebGUI::Shop::ShipDriver;
|
||||
use WebGUI::Pluggable;
|
||||
|
|
@ -104,8 +103,9 @@ A WebGUI::Session object. A WebGUI::Error::InvalidParam exception will be throw
|
|||
sub getOptions {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
croak "Definition requires a session object"
|
||||
WebGUI::Error::InvalidParam->throw(error => q{Must provide a session variable})
|
||||
unless ref $session eq 'WebGUI::Session';
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -273,8 +273,11 @@ sub new {
|
|||
my $properties = $session->db->quickHashRef('select * from shipper where shipperId=?',[$shipperId]);
|
||||
WebGUI::Error::ObjectNotFound->throw(error => q{shipperId not found in db}, id => $shipperId)
|
||||
unless scalar keys %{ $properties };
|
||||
croak "Somehow, the options property of this object, $shipperId, got broken in the db"
|
||||
unless exists $properties->{options} and $properties->{options};
|
||||
##This check is just to guardband the from_json call below.
|
||||
WebGUI::Error::InvalidParam->throw(
|
||||
error => qq{Options property for $shipperId was broken in the db},
|
||||
param => $properties->{options},
|
||||
) unless $properties->{options}; ##Note, existence is controlled by the columns in the db
|
||||
my $options = from_json($properties->{options});
|
||||
my $self = WebGUI::Shop::ShipDriver->_buildObj($session, $class, $shipperId, $options);
|
||||
return $self;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue