Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add cleanup for Shop::Vendors. More end block removal.
  • Loading branch information
perlDreamer committed Jun 8, 2010
1 parent 41b7413 commit b728eab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 deletions.
20 changes: 3 additions & 17 deletions t/Shop/Pay.t
Expand Up @@ -33,8 +33,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests

my $tests = 18;
plan tests => 1 + $tests;
plan tests => 18;

#----------------------------------------------------------------------------
# put your tests here
Expand All @@ -45,10 +44,6 @@ my $storage;
my $newDriver;
my $anotherDriver;

SKIP: {

skip 'Unable to load module WebGUI::Shop::Pay', $tests unless $loaded;

#######################################################################
#
# new
Expand Down Expand Up @@ -127,6 +122,7 @@ my $options = {
label => 'Cold, stone hard cash',
};
$newDriver = $pay->addPaymentGateway('WebGUI::Shop::PayDriver::Cash', $options);
WebGUI::Test->addToCleanup($newDriver);
isa_ok($newDriver, 'WebGUI::Shop::PayDriver::Cash', 'added a new, configured Cash driver');
is($newDriver->get('label'), 'Cold, stone hard cash', 'label passed correctly to paydriver');

Expand Down Expand Up @@ -207,6 +203,7 @@ my $otherOptions = {
label => 'Even harder cash',
};
$anotherDriver = $pay->addPaymentGateway('WebGUI::Shop::PayDriver::Cash', $otherOptions);
WebGUI::Test->addToCleanup($anotherDriver);

my $gateways = $pay->getPaymentGateways;
my @returnedIds = map {$_->get('label')} @{ $gateways };
Expand All @@ -232,14 +229,3 @@ cmp_bag(
#
#######################################################################


}

#----------------------------------------------------------------------------
# Cleanup
END {
defined $newDriver and $newDriver->delete;
defined $newDriver and $anotherDriver->delete;
my $count = $session->db->quickScalar('select count(*) from paymentGateway');
is($count, 2, 'WebGUI ships with two drivers by default');
}
13 changes: 1 addition & 12 deletions t/Shop/ShipDriver.t
Expand Up @@ -43,10 +43,6 @@ my $loaded = use_ok('WebGUI::Shop::ShipDriver');

my $storage;

SKIP: {

skip 'Unable to load module WebGUI::Shop::ShipDriver', $tests unless $loaded;

#######################################################################
#
# definition
Expand Down Expand Up @@ -163,6 +159,7 @@ my $options = {
};

$driver = WebGUI::Shop::ShipDriver->create( $session, $options );
WebGUI::Test->addToCleanup($driver);

isa_ok($driver, 'WebGUI::Shop::ShipDriver');

Expand Down Expand Up @@ -398,11 +395,3 @@ my $count = $session->db->quickScalar('select count(*) from shipper where shippe
is($count, 0, 'delete deleted the object');

undef $driver;


}

#----------------------------------------------------------------------------
# Cleanup
END {
}
18 changes: 4 additions & 14 deletions t/Shop/Vendor.t
Expand Up @@ -31,8 +31,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests

my $tests = 49;
plan tests => 1 + $tests;
plan tests => 49;

#----------------------------------------------------------------------------
# put your tests here
Expand All @@ -47,10 +46,6 @@ my $guardUser = WebGUI::User->new($session, 'new');
$guardUser->username('guard');
WebGUI::Test->usersToDelete($fenceUser, $guardUser);

SKIP: {

skip 'Unable to load module WebGUI::Shop::Vendor', $tests unless $loaded;

$numberOfVendors = scalar @{ WebGUI::Shop::Vendor->getVendors($session) };

#######################################################################
Expand Down Expand Up @@ -130,6 +125,7 @@ cmp_deeply(
my $now = WebGUI::DateTime->new($session, time);

eval { $fence = WebGUI::Shop::Vendor->create($session, { userId => $fenceUser->userId, }); };
WebGUI::Test->addToCleanup($fence);
$e = Exception::Class->caught();
ok(!$e, 'No exception thrown by create');
isa_ok($vendor, 'WebGUI::Shop::Vendor', 'create returns correct type of object');
Expand Down Expand Up @@ -251,6 +247,7 @@ my $defaultVendor = WebGUI::Shop::Vendor->newByUserId($session, 3);
#######################################################################

$guard = WebGUI::Shop::Vendor->create($session, { userId => $guardUser->userId, name => q|Warden Norton|});
WebGUI::Test->addToCleanup($guard);
my $vendorsList = WebGUI::Shop::Vendor->getVendors($session);
cmp_deeply(
$vendorsList,
Expand Down Expand Up @@ -307,11 +304,4 @@ foreach (keys %completeProps ) {

undef $guard;

}

#----------------------------------------------------------------------------
# Cleanup
END {
$fence->delete;
is( scalar @{ WebGUI::Shop::Vendor->getVendors($session) }, $numberOfVendors, 'No vendors leaked');
}
#vim:ft=perl
2 changes: 2 additions & 0 deletions t/lib/WebGUI/Test.pm
Expand Up @@ -796,6 +796,7 @@ were passed in. Currently able to destroy:
WebGUI::Shop::ShipDriver
WebGUI::Shop::PayDriver
WebGUI::Shop::Transaction
WebGUI::Shop::Vendor
WebGUI::Shop::AddressBook
WebGUI::DatabaseLink
WebGUI::LDAPLink
Expand Down Expand Up @@ -888,6 +889,7 @@ Example call:
'WebGUI::Shop::Transaction' => 'delete',
'WebGUI::Shop::ShipDriver' => 'delete',
'WebGUI::Shop::PayDriver' => 'delete',
'WebGUI::Shop::Vendor' => 'delete',
'WebGUI::Inbox::Message' => 'purge',
'WebGUI::Shop::Cart' => sub {
my $cart = shift;
Expand Down

0 comments on commit b728eab

Please sign in to comment.