From e17569c6f75f32d8948503bf9f190763983a0a29 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 15 Jun 2008 21:56:56 +0000 Subject: [PATCH] clean up cleaning up and make the getPaymentGateways test more robust --- t/Shop/Pay.t | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/t/Shop/Pay.t b/t/Shop/Pay.t index ad683a1e7..55a87330d 100644 --- a/t/Shop/Pay.t +++ b/t/Shop/Pay.t @@ -33,7 +33,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 18; +my $tests = 19; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -42,6 +42,8 @@ plan tests => 1 + $tests; my $loaded = use_ok('WebGUI::Shop::Pay'); my $storage; +my $newDriver; +my $anotherDriver; SKIP: { @@ -133,7 +135,7 @@ my $options = { enabled => 1, label => 'Cold, stone hard cash', }; -my $newDriver = $pay->addPaymentGateway('WebGUI::Shop::PayDriver::Cash', 'JAL', $options); +$newDriver = $pay->addPaymentGateway('WebGUI::Shop::PayDriver::Cash', 'JAL', $options); isa_ok($newDriver, 'WebGUI::Shop::PayDriver::Cash', 'added a new, configured Cash driver'); is($newDriver->label, 'JAL', 'label passed correctly to paydriver'); @@ -210,15 +212,14 @@ my $otherOptions = { enabled => 1, label => 'Even harder cash', }; -my $anotherDriver = $pay->addPaymentGateway('WebGUI::Shop::PayDriver::Cash', 'Pomade', $otherOptions); +$anotherDriver = $pay->addPaymentGateway('WebGUI::Shop::PayDriver::Cash', 'Pomade', $otherOptions); my $gateways = $pay->getPaymentGateways; -my @returnedIds = map {$_->getId} @{ $gateways }; +my @returnedIds = map {$_->label} @{ $gateways }; cmp_bag( \@returnedIds, [ - $newDriver->getId, - $anotherDriver->getId, + qw/Cash ITransact Pomade JAL/ ], 'getPaymentGateways returns all create payment drivers', ); @@ -243,5 +244,8 @@ cmp_bag( #---------------------------------------------------------------------------- # Cleanup END { - $session->db->write('delete from paymentGateway'); + 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'); }