more robust testing platform, #37340
[freeside.git] / FS / t / suite / 00-new_customer.t
1 #!/usr/bin/perl
2
3 use FS::Test;
4 use Test::More tests => 4;
5
6 my $FS = FS::Test->new;
7 # get the form
8 $FS->post('/edit/cust_main.cgi');
9 my $form = $FS->form('CustomerForm');
10
11 my %params = (
12   residential_commercial  => 'Residential',
13   agentnum                => 1,
14   refnum                  => 1,
15   last                    => 'Customer',
16   first                   => 'New',
17   invoice_email           => 'newcustomer@fake.freeside.biz',
18   bill_address1           => '123 Example Street',
19   bill_address2           => 'Apt. Z',
20   bill_city               => 'Sacramento',
21   bill_state              => 'CA',
22   bill_zip                => '94901',
23   bill_country            => 'US',
24   bill_coord_auto         => 'Y',
25   daytime                 => '916-555-0100',
26   night                   => '916-555-0200',
27   ship_address1           => '125 Example Street',
28   ship_address2           => '3rd Floor',
29   ship_city               => 'Sacramento',
30   ship_state              => 'CA',
31   ship_zip                => '94901',
32   ship_country            => 'US',
33   ship_coord_auto         => 'Y',
34   invoice_ship_address    => 'Y',
35   postal_invoice          => 'Y',
36   billday                 => '1',
37   no_credit_limit         => 1,
38   # payment method
39   custpaybynum0_payby         => 'CARD',
40   custpaybynum0_payinfo       => '4012888888881881',
41   custpaybynum0_paydate_month => '12',
42   custpaybynum0_paydate_year  => '2020',
43   custpaybynum0_paycvv        => '123',
44   custpaybynum0_payname       => '',
45   custpaybynum0_weight        => 1,
46 );
47 foreach (keys %params) {
48   $form->value($_, $params{$_});
49 }
50 $FS->post($form);
51 ok( $FS->error eq '' , 'form posted' );
52 if (
53   ok($FS->redirect =~ m[^/view/cust_main.cgi\?(\d+)], 'new customer accepted')
54 ) {
55   my $custnum = $1;
56   my $cust = $FS->qsearchs('cust_main', { custnum => $1 });
57   isa_ok ( $cust, 'FS::cust_main' );
58   $FS->post($FS->redirect);
59   ok ( $FS->error eq '' , 'can view customer' );
60 } else {
61   # try to display the error message, or if not, show everything
62   $FS->post($FS->redirect);
63   diag ($FS->error);
64   done_testing(2);
65 }
66
67 1;