4 use Test::More tests => 8;
7 ### can only run on test database (company name "Freeside Test")
8 ### will run upgrade, which uses lots of prints & warns beyond regular test output
10 my $fs = FS::Test->new( user => 'admin' );
11 my $conf = new_ok('FS::Conf');
15 like( $conf->config('company_name'), qr/^Freeside Test/, 'using test database' ) or BAIL_OUT('');
17 # some pre-upgrade cleanup, upgrade will fail if these are still configured
18 foreach my $cust_main ( $fs->qsearch('cust_main') ) {
19 my @count = $fs->qsearch('agent_payment_gateway', { agentnum => $cust_main->agentnum } );
21 note("DELETING CARDTYPE GATEWAYS");
22 foreach my $apg (@count) {
23 $err = $apg->delete if $apg->cardtype;
26 @count = $fs->qsearch('agent_payment_gateway', { agentnum => $cust_main->agentnum } );
28 $err = "Still found ".@count." gateways for custnum ".$cust_main->custnum;
33 ok( !$err, "remove obsolete payment gateways" ) or BAIL_OUT($err);
38 $conf->set('business-onlinepayment' => $bopconf);
39 is( join("\n",$conf->config('business-onlinepayment')), $bopconf, "setting first default gateway" ) or BAIL_OUT('');
41 $err = system('freeside-upgrade','admin');
42 ok( !$err, 'initial upgrade' ) or BAIL_OUT('Error string: '.$!);
56 /usr/local/etc/freeside/cardfortresstest.txt';
57 $conf->set('business-onlinepayment' => $bopconf);
58 is( join("\n",$conf->config('business-onlinepayment')), $bopconf, "setting tokenizable default gateway" ) or BAIL_OUT('');
60 foreach my $pg ($fs->qsearch('payment_gateway')) {
61 unless ($pg->gateway_module eq 'CardFortress') {
62 note('UPGRADING NON-CF PAYMENT GATEWAY');
64 gateway => $pg->gateway_module,
65 gateway_login => $pg->gateway_username,
66 gateway_password => $pg->gateway_password,
67 private_key => '/usr/local/etc/freeside/cardfortresstest.txt',
69 $pg->gateway_module('CardFortress');
70 $pg->gateway_username('cardfortresstest');
71 $pg->gateway_password('(TEST54)');
72 $err = $pg->replace(\%pgopts);
76 ok( !$err, "remove non-CF payment gateways" ) or BAIL_OUT($err);
78 $err = system('freeside-upgrade','admin');
79 ok( !$err, 'tokenizable upgrade' ) or BAIL_OUT('Error string: '.$!);