5 use Test::More tests => 9;
7 { # fake test driver 1 (no _info hash)
9 package Business::OnlinePayment::MOCK1;
12 use base qw(Business::OnlinePayment);
15 { # fake test driver 2 (with _info hash)
17 package Business::OnlinePayment::MOCK2;
18 use base qw(Business::OnlinePayment::MOCK1);
21 'info_compat' => '0.01', # always 0.01 for now,
22 # 0.02 will have requirements
23 'gateway_name' => 'Example Gateway',
24 'gateway_url' => 'http://www.example.com/',
25 'module_version' => '0.01', #$VERSION,
26 'supported_types' => [ qw( CC ECHECK ) ],
27 'token_support' => 0, #card storage/tokenization support
28 'test_transaction' => 0, #set true if ->test_transaction(1) works
29 'supported_actions' => [
30 'Normal Authorization',
36 'CC_void_requires_card' => 1,
41 my $package = "Business::OnlinePayment";
42 my @drivers = qw(MOCK1 MOCK2);
43 my $driver = $drivers[0];
45 # trick to make use() happy (called in Business::OnlinePayment->new)
46 foreach my $drv (@drivers) {
47 $INC{"Business/OnlinePayment/${drv}.pm"} = "testing";
51 my $obj = $package->new($driver);
52 isa_ok( $obj, $package );
53 isa_ok( $obj, $package . "::" . $driver );
55 my %throwaway_actions = eval { $obj->info('supported_actions') };
56 ok( !$@, "->info('supported_actions') works w/o gateway module introspection");
60 $obj = $package->new($driver);
61 isa_ok( $obj, $package );
62 isa_ok( $obj, $package . "::" . $driver );
64 my %actions = eval { $obj->info('supported_actions') };
65 ok( grep { $_ eq 'Void' } @{ $actions{$_} },
66 "->info('supported_actions') works w/gateway module introspection ($_)"
67 ) foreach qw( CC ECHECK );
69 ok($obj->info('CC_void_requires_card'),
70 'CC_void_requires_card introspection');
71 ok(!$obj->info('ECHECK_void_requires_account'),
72 'ECHECK_void_requires_account introspection');