Option to disable the charging of the setup fee while a package is suspended.
[freeside.git] / install / 5.005 / DBD-Pg-1.22-fixvercmp / t / 04execute.t
1 use strict;
2 use DBI;
3 use Test::More;
4
5 if (defined $ENV{DBI_DSN}) {
6   plan tests => 13;
7 } else {
8   plan skip_all => 'cannot test without DB info';
9 }
10
11 my $dbh = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
12                        {RaiseError => 1, AutoCommit => 0}
13                       );
14 ok(defined $dbh,
15    'connect with transaction'
16   );
17
18 my $sql = <<SQL;
19   SELECT id
20   , name
21   FROM test
22   WHERE id = ?
23 SQL
24 my $sth = $dbh->prepare($sql);
25 ok(defined $sth,
26    "prepare: $sql"
27   );
28
29 $sth->bind_param(1, 1);
30 ok($sth->execute(),
31    'exectute with one bind param'
32   );
33
34 $sth->bind_param(1, 2);
35 ok($sth->execute(),
36    'exectute with rebinding one param'
37   );
38
39 $sql = <<SQL;
40        SELECT id
41        , name
42        FROM test
43        WHERE id = ?
44        AND name = ?
45 SQL
46 $sth = $dbh->prepare($sql);
47 ok(defined $sth,
48    "prepare: $sql"
49   );
50
51 $sth->bind_param(1, 2);
52 $sth->bind_param(2, 'foo');
53 ok($sth->execute(),
54    'exectute with two bind params'
55   );
56
57 eval {
58   local $dbh->{PrintError} = 0;
59   $sth = $dbh->prepare($sql);
60   $sth->bind_param(1, 2);
61   $sth->execute();
62 };
63 ok(!$@,
64   'execute with only first of two params bound'
65   );
66
67 eval {
68   local $dbh->{PrintError} = 0;
69   $sth = $dbh->prepare($sql);
70   $sth->bind_param(2, 'foo');
71   $sth->execute();
72 };
73 ok(!$@,
74   'execute with only second of two params bound'
75   );
76
77 eval {
78   local $dbh->{PrintError} = 0;
79   $sth = $dbh->prepare($sql);
80   $sth->execute();
81 };
82 ok(!$@,
83   'execute with neither of two params bound'
84   );
85
86 $sth = $dbh->prepare($sql);
87 ok($sth->execute(1, 'foo'),
88    'execute with both params bound in execute'
89    );
90
91 eval {
92   local $dbh->{PrintError} = 0;
93   $sth = $dbh->prepare(q{
94                          SELECT id
95                          , name
96                          FROM test
97                          WHERE id = ?
98                          AND name = ?
99                         });
100   $sth->execute(1);
101 };
102 ok($@,
103   'execute with only one of two params bound in execute'
104   );
105
106
107 ok($sth->finish(),
108    'finish'
109    );
110
111 ok($dbh->disconnect(),
112    'disconnect'
113   );