added dbi_options attribute
|
1 |
use Test::More; |
2 |
use strict; |
|
3 |
use warnings; |
|
4 | ||
5 |
# user password database |
|
6 |
our ($USER, $PASSWORD, $DATABASE) = connect_info(); |
|
7 | ||
8 |
plan skip_all => 'private MySQL test' unless $USER; |
|
9 | ||
10 |
plan 'no_plan'; |
|
11 | ||
12 |
use DBIx::Custom; |
|
13 |
use Scalar::Util 'blessed'; |
|
14 |
{ |
|
15 |
my $dbi = DBIx::Custom->connect( |
|
16 |
user => $USER, |
|
17 |
password => $PASSWORD, |
|
18 |
data_source => "dbi:mysql:dbname=$DATABASE" |
|
19 |
); |
|
20 |
$dbi->connect; |
|
21 |
|
|
22 |
ok(blessed $dbi->dbh); |
|
23 |
can_ok($dbi->dbh, qw/prepare/); |
|
24 |
ok($dbi->dbh->{AutoCommit}); |
|
25 |
ok(!$dbi->dbh->{mysql_enable_utf8}); |
|
26 |
} |
|
27 | ||
28 |
{ |
|
29 |
my $dbi = DBIx::Custom->connect( |
|
30 |
user => $USER, |
|
31 |
password => $PASSWORD, |
|
32 |
data_source => "dbi:mysql:dbname=$DATABASE", |
|
33 |
dbi_options => {AutoCommit => 0, mysql_enable_utf8 => 1} |
|
34 |
); |
|
35 |
$dbi->connect; |
|
36 |
ok(!$dbi->dbh->{AutoCommit}); |
|
37 |
ok($dbi->dbh->{mysql_enable_utf8}); |
|
38 |
} |
|
39 | ||
40 |
sub connect_info { |
|
41 |
my $file = 'password.tmp'; |
|
42 |
open my $fh, '<', $file |
|
43 |
or return; |
|
44 |
|
|
45 |
my ($user, $password, $database) = split(/\s/, (<$fh>)[0]); |
|
46 |
|
|
47 |
close $fh; |
|
48 |
|
|
49 |
return ($user, $password, $database); |
|
50 |
} |