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 / 11quoting.t
1 use strict;
2 use DBI;
3 use Test::More;
4
5 if (defined $ENV{DBI_DSN}) {
6   plan tests => 8;
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 %tests = (
19              one=>["'", "'\\" . sprintf("%03o", ord("'")) . "'"],
20              two=>["''", "'" . ("\\" . sprintf("%03o", ord("'")))x2 . "'"],
21              three=>["\\", "'\\" . sprintf("%03o", ord("\\")) . "'"],
22              four=>["\\'", sprintf("'\\%03o\\%03o'", ord("\\"), ord("'"))],
23              five=>["\\'?:", sprintf("'\\%03o\\%03o?:'", ord("\\"), ord("'"))],
24             );
25
26 foreach my $test (keys %tests) {
27   my ($unq, $quo, $ref);
28
29   $unq = $tests{$test}->[0];
30   $ref = $tests{$test}->[1];
31   $quo = $dbh->quote($unq);
32
33   ok($quo eq $ref,
34      "$test: $unq -> expected $quo got $ref"
35     );
36 }
37
38 # Make sure that SQL_BINARY doesn't work.
39 #    eval { $dbh->quote('foo', { TYPE => DBI::SQL_BINARY })};
40 eval {
41   local $dbh->{PrintError} = 0;
42   $dbh->quote('foo', DBI::SQL_BINARY);
43 };
44 ok($@ && $@ =~ /Use of SQL_BINARY invalid in quote/,
45    'SQL_BINARY'
46 );
47
48 ok($dbh->disconnect(),
49    'disconnect'
50   );