line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::Driver::DBI::t::CHIDriverTests::Base; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$CHI::Driver::DBI::t::CHIDriverTests::Base::VERSION = '1.26'; |
4
|
|
|
|
|
|
|
} |
5
|
2
|
|
|
2
|
|
14554
|
use DBI; |
|
2
|
|
|
|
|
75443
|
|
|
2
|
|
|
|
|
169
|
|
6
|
2
|
|
|
2
|
|
19643
|
use Module::Load::Conditional qw(can_load); |
|
2
|
|
|
|
|
96140
|
|
|
2
|
|
|
|
|
158
|
|
7
|
2
|
|
|
2
|
|
2958
|
use Test::More; |
|
2
|
|
|
|
|
42897
|
|
|
2
|
|
|
|
|
21
|
|
8
|
2
|
|
|
2
|
|
683
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
64
|
|
9
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
10
|
2
|
|
|
2
|
|
10
|
use base qw(CHI::t::Driver); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
5243
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub testing_driver_class { 'CHI::Driver::DBI' } |
13
|
|
|
|
|
|
|
sub supports_get_namespaces { 0 } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub SKIP_CLASS { |
16
|
|
|
|
|
|
|
my $class = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
if ( not $class->dbh() ) { |
19
|
|
|
|
|
|
|
return "Unable to get a database connection"; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub dbh { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
eval { |
29
|
|
|
|
|
|
|
return DBI->connect( |
30
|
|
|
|
|
|
|
$self->dsn(), |
31
|
|
|
|
|
|
|
'', '', |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
RaiseError => 0, |
34
|
|
|
|
|
|
|
PrintError => 0, |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new_cache_options { |
41
|
|
|
|
|
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return ( |
44
|
|
|
|
|
|
|
$self->SUPER::new_cache_options(), |
45
|
|
|
|
|
|
|
dbh => $self->dbh, |
46
|
|
|
|
|
|
|
create_table => 1 |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub test_with_dbix_connector : Tests(1) { |
51
|
|
|
|
|
|
|
return 'DBIx::Connector not installed' |
52
|
|
|
|
|
|
|
unless can_load( modules => { 'DBIx::Connector' => undef } ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
my $conn = DBIx::Connector->new( $self->dsn() ); |
56
|
|
|
|
|
|
|
my $cache = CHI->new( driver => 'DBI', dbh => $conn ); |
57
|
|
|
|
|
|
|
$cache->clear(); |
58
|
|
|
|
|
|
|
my $t = time; |
59
|
|
|
|
|
|
|
$cache->set( 'foo', $t ); |
60
|
|
|
|
|
|
|
is( $cache->get('foo'), $t ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub test_with_dbi_generator : Tests(1) { |
64
|
|
|
|
|
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
my $dbh = $self->dbh; |
66
|
|
|
|
|
|
|
my $cache = CHI->new( driver => 'DBI', dbh => sub { $dbh } ); |
67
|
|
|
|
|
|
|
$cache->clear(); |
68
|
|
|
|
|
|
|
my $t = time; |
69
|
|
|
|
|
|
|
$cache->set( 'foo', $t ); |
70
|
|
|
|
|
|
|
is( $cache->get('foo'), $t ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |