From d3c17b9586c08aedbc5cc640062459e147a8e632 Mon Sep 17 00:00:00 2001 From: fbriere Date: Fri, 17 Feb 2006 00:11:46 +0000 Subject: [PATCH] Rewrote the whole parsing test suite --- t/30parse.t | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/t/30parse.t b/t/30parse.t index 2917a47..44feb56 100755 --- a/t/30parse.t +++ b/t/30parse.t @@ -1,29 +1,55 @@ -use Test::More tests => 1 + 2 * 6; +use constant FIELDS => qw( + result_code authorization error_message + receipt_number order_number + card_type + avs_response cvv2_response + total_amount + ); -BEGIN { use_ok('Business::OnlinePayment') }; +use constant RESULTS => ( + { + is_success => 1, + result_code => '2000', + authorization => 'T00000', + error_message => 'Test Approved', + receipt_number => '1096019995.5012', + order_number => 0, + card_type => undef, + avs_response => undef, + cvv2_response => undef, + total_amount => 3.88, + }, + { + is_success => 0, + result_code => '98e05', + authorization => undef, + error_message => 'Real error message', + receipt_number => '1096021915.5853', + order_number => 729, + card_type => 'Visa', + avs_response => undef, + cvv2_response => undef, + total_amount => 3.88, + }, + ); -use constant FIELDS => (qw( result_code authorization total_amount - error_message )); +use Test::More tests => 1 + scalar(RESULTS) * (1 + 1 + scalar(FIELDS)); + +BEGIN { use_ok('Business::OnlinePayment') }; -use constant RESULTS => ( - [ 1, '2000', 'T00000', 3.88, 'Test Approved' ], - [ 0, '98e05', undef, 3.88, 'Real error message' ], - ); my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000'; $/ = ''; -foreach (RESULTS) { - my @results = @$_; - +foreach my $results (RESULTS) { my $xml = ; $txn->parse_response($xml); is($txn->server_response, $xml, 'server_response'); - if (shift @results) { + if ($results->{is_success}) { ok($txn->is_success, 'expecting success'); } else { ok(!$txn->is_success, 'expecting failure'); @@ -31,7 +57,7 @@ foreach (RESULTS) { foreach (FIELDS) { no strict 'refs'; - is($txn->$_, shift @results, $_); + is($txn->$_, $results->{$_}, $_); } } -- 2.11.0