diff --git a/lib/WebGUI/Shop/ShipDriver.pm b/lib/WebGUI/Shop/ShipDriver.pm index 8930659f9..0bdb285ec 100644 --- a/lib/WebGUI/Shop/ShipDriver.pm +++ b/lib/WebGUI/Shop/ShipDriver.pm @@ -49,7 +49,6 @@ sub _buildObj { bless $self, $class; register $self; - my $shipperId = $session->id->generate; my $id = id $self; $session{ $id } = $session; @@ -207,7 +206,7 @@ sub new { unless exists $properties->{options} and $properties->{options}; my $options = from_json($properties->{options}); my $self = WebGUI::Shop::ShipDriver->_buildObj($session, $shipperId, $options); - return; + return $self; } #------------------------------------------------------------------- diff --git a/t/Shop/ShipDriver.t b/t/Shop/ShipDriver.t index eb24ea27c..41ab549b6 100644 --- a/t/Shop/ShipDriver.t +++ b/t/Shop/ShipDriver.t @@ -29,7 +29,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 18; +my $tests = 21; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -154,19 +154,6 @@ is ($driver->getName, 'Shipper Driver', 'getName returns the human readable name # ####################################################################### -####################################################################### -# -# delete -# -####################################################################### - -$driver->delete; - -my $count = $session->db->quickScalar('select count(*) from shipper where shipperId=?',[$driver->shipperId]); -is($count, 0, 'delete deleted the object'); - -undef $driver; - ####################################################################### # # new @@ -184,6 +171,25 @@ like ($@, qr/^new requires a shipperId/, 'new croaks without a shipperId'); eval { $oldDriver = WebGUI::Shop::ShipDriver->new($session, 'notEverAnId'); }; like ($@, qr/^The requested shipperId does not exist in the db/, 'new croaks unless the requested shipperId object exists in the db'); +my $driverCopy = WebGUI::Shop::ShipDriver->new($session, $driver->shipperId); + +is($driver->getId, $driverCopy->getId, 'same id'); +is($driver->className, $driverCopy->className, 'same className'); +cmp_deeply($driver->options, $driverCopy->options, 'same options'); + +####################################################################### +# +# delete +# +####################################################################### + +$driver->delete; + +my $count = $session->db->quickScalar('select count(*) from shipper where shipperId=?',[$driver->shipperId]); +is($count, 0, 'delete deleted the object'); + +undef $driver; + ####################################################################### # # calculate