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