fixed up MANIFEST so that debuild passes ; not running tests unless environment varia...
[Business-OnlinePayment-Exact.git] / t / Business-OnlinePayment-Exact.t
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl Business-OnlinePayment-Exact.t'
3
4 #########################
5
6 # change 'tests => 1' to 'tests => last_test_to_print';
7
8 use Test::More;
9 use Term::ReadLine;
10
11 BEGIN {
12   unless ( $ENV{RELEASE_TESTING} ) {
13     my $msg = 'Author test.  Set $ENV{RELEASE_TESTING} to a true value to run.';
14     plan( skip_all => $msg );
15     done_testing();
16     exit(0);
17   }
18   use_ok('Business::OnlinePayment::Exact');
19 };
20
21 #########################
22
23 # Insert your test code below, the Test::More module is use()ed here so read
24 # its man page ( perldoc Test::More ) for help writing this test script.
25
26 my $term = new Term::ReadLine 'E-Xact Test';
27 diag("Please enter a test account for E-Xact");
28 my $prompt = "ExactID: ";
29 my $login = $term->readline($prompt);
30 diag("Please enter the password for the test account $login");
31 $prompt = "Password: ";
32 my $pass = $term->readline($prompt);
33 diag("Please enter a valid credit card to test (it will not be charged)");
34 $prompt = "Card Number: ";
35 my $card = $term->readline($prompt);
36 diag("Please enter an expiry date for the card in the form MMYY");
37 $prompt = "Expiry: ";
38 my $expiry = $term->readline($prompt);
39 diag("Please enter a name to match the card");
40 $prompt = "Name: ";
41 my $name = $term->readline($prompt);
42
43 my $tx;
44 ok($tx = new Business::OnlinePayment('Exact'), 'New Exact');
45 ok($tx->content(
46     amount => '0.01',
47     card_number => $card,
48     expiration => $expiry,
49     name => $name,
50     action => 'normal authorization',
51     login => $login,
52     password => $pass,
53     referer => 'Business::OnlinePayment::Exact testing',
54     ),
55     'Add Some Content');
56
57 my $return = eval { $tx->test_transaction(1) };
58
59 my $error = $@;
60
61 ok($error, 'enable test mode dies');
62
63 ok($tx->submit(), 'submit');
64
65 ok($tx->is_success(), 'Success!!!')
66   or diag "Card was rejected: ", $tx->error_message();
67
68 my $auth;
69 ok($auth = $tx->authorization(), "authorization $auth");
70 my $err;
71 ok($err = $tx->error_message(), "error $err");
72 my $on;
73 ok($on = $tx->order_number(), "order number $on");
74
75
76 done_testing();