DBIx-Custom / t / dbix-custom-core-mysql-private.t /
Newer Older
52 lines | 1.151kb
added dbi_options attribute
kimoto authored on 2010-12-20
1
use Test::More;
2
use strict;
3
use warnings;
4

            
added warnings
Yuki Kimoto authored on 2011-06-07
5
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
6

            
added dbi_options attribute
kimoto authored on 2010-12-20
7
# user password database
8
our ($USER, $PASSWORD, $DATABASE) = connect_info();
9

            
10
plan skip_all => 'private MySQL test' unless $USER;
11

            
12
plan 'no_plan';
13

            
14
use DBIx::Custom;
15
use Scalar::Util 'blessed';
16
{
17
    my $dbi = DBIx::Custom->connect(
18
        user => $USER,
19
        password => $PASSWORD,
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
20
        dsn => "dbi:mysql:dbname=$DATABASE"
added dbi_options attribute
kimoto authored on 2010-12-20
21
    );
22
    $dbi->connect;
23
    
24
    ok(blessed $dbi->dbh);
25
    can_ok($dbi->dbh, qw/prepare/);
26
    ok($dbi->dbh->{AutoCommit});
27
    ok(!$dbi->dbh->{mysql_enable_utf8});
28
}
29

            
30
{
31
    my $dbi = DBIx::Custom->connect(
32
        user => $USER,
33
        password => $PASSWORD,
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
34
        dsn => "dbi:mysql:dbname=$DATABASE",
added dbi_options attribute
kimoto authored on 2010-12-20
35
        dbi_options => {AutoCommit => 0, mysql_enable_utf8 => 1}
36
    );
37
    $dbi->connect;
38
    ok(!$dbi->dbh->{AutoCommit});
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
39
    #ok($dbi->dbh->{mysql_enable_utf8});
added dbi_options attribute
kimoto authored on 2010-12-20
40
}
41

            
42
sub connect_info {
43
    my $file = 'password.tmp';
44
    open my $fh, '<', $file
45
      or return;
46
    
47
    my ($user, $password, $database) = split(/\s/, (<$fh>)[0]);
48
    
49
    close $fh;
50
    
51
    return ($user, $password, $database);
52
}