Move the delete test after the new test, so that there's an object

to pull from the db.  Sheesh.
Remove the id generation from inside the private build method
and make sure it returns the built object.
This commit is contained in:
Colin Kuskie 2008-02-23 06:17:39 +00:00
parent 669bb870eb
commit 39aa431e2c
2 changed files with 21 additions and 16 deletions

View file

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