line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Interchange6::Test::Role::MySQL; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Interchange6::Test::Role::MySQL |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1663
|
use File::Temp qw/tempdir/; |
|
1
|
|
|
|
|
17012
|
|
|
1
|
|
|
|
|
84
|
|
10
|
1
|
|
|
1
|
|
605
|
use Test::Roo::Role; |
|
1
|
|
|
|
|
555
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
with 'Interchange6::Test::Role::Database'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 METHODS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
See also L<Interchange6::Test::Role::Database> which is consumed by this role. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 BUILD |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Check that all required modules load or else plan skip_all |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub BUILD { |
24
|
1
|
|
|
1
|
1
|
230784
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
1
|
|
497
|
eval 'use DateTime::Format::MySQL; 1' |
|
1
|
|
|
|
|
75503
|
|
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
68
|
|
27
|
|
|
|
|
|
|
or plan skip_all => "DateTime::Format::MySQL required to run these tests"; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
1
|
|
260
|
eval 'use DBD::mysql; 1' |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
67
|
|
30
|
|
|
|
|
|
|
or plan skip_all => "DBD::mysql required to run these tests"; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
eval 'use Test::mysqld; 1' |
33
|
|
|
|
|
|
|
or plan skip_all => "Test::mysqld required to run these tests"; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
eval { $self->database } |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
or plan skip_all => "Init database failed: $@"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $tmpdir = tempdir( |
40
|
|
|
|
|
|
|
CLEANUP => 1, |
41
|
|
|
|
|
|
|
TEMPLATE => 'ic6s_test_XXXXX', |
42
|
|
|
|
|
|
|
TMPDIR => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _build_database { |
46
|
0
|
|
|
0
|
|
|
my $self = shift; |
47
|
1
|
|
|
1
|
|
1516
|
no warnings 'once'; # prevent: "Test::mysqld::errstr" used only once |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
435
|
|
48
|
0
|
0
|
|
|
|
|
my $mysqld = Test::mysqld->new( |
49
|
|
|
|
|
|
|
base_dir => $tmpdir, |
50
|
|
|
|
|
|
|
my_cnf => { |
51
|
|
|
|
|
|
|
'character-set-server' => 'utf8', |
52
|
|
|
|
|
|
|
'collation-server' => 'utf8_unicode_ci', |
53
|
|
|
|
|
|
|
'skip-networking' => '', |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
) or die $Test::mysqld::errstr; |
56
|
0
|
|
|
|
|
|
return $mysqld; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _build_dbd_version { |
60
|
0
|
|
|
0
|
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
return |
62
|
|
|
|
|
|
|
"DBD::mysql $DBD::mysql::VERSION Test::mysqld " |
63
|
|
|
|
|
|
|
. "$Test::mysqld::VERSION mysql_clientversion " |
64
|
0
|
|
|
|
|
|
. $self->ic6s_schema->storage->dbh->{mysql_clientversion}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 connect_info |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns appropriate DBI connect info for this role. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub connect_info { |
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
return ( |
76
|
0
|
|
|
|
|
|
$self->database->dsn( dbname => 'test' ), |
77
|
|
|
|
|
|
|
undef, undef, |
78
|
|
|
|
|
|
|
{ |
79
|
|
|
|
|
|
|
mysql_enable_utf8 => 1, |
80
|
|
|
|
|
|
|
on_connect_call => 'set_strict_mode', |
81
|
|
|
|
|
|
|
quote_names => 1, |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _build_database_info { |
87
|
0
|
|
|
0
|
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
$self->ic6s_schema->storage->dbh_do( |
89
|
|
|
|
|
|
|
sub { |
90
|
0
|
|
|
0
|
|
|
my ( $storage, $dbh ) = @_; |
91
|
0
|
|
|
|
|
|
my $variables = $dbh->selectall_arrayref(q(SHOW VARIABLES)); |
92
|
0
|
|
|
|
|
|
my @info = map { $_->[0] =~ s/_server//; "$_->[0]=$_->[1]" } grep { |
|
0
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
$_->[0] =~ /^(version|character_set_server|collation_server)/ |
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
&& $_->[0] !~ /compile/ |
95
|
|
|
|
|
|
|
} @$variables; |
96
|
1
|
|
|
1
|
|
548
|
use DBI::Const::GetInfoType; |
|
1
|
|
|
|
|
6023
|
|
|
1
|
|
|
|
|
260
|
|
97
|
0
|
|
|
|
|
|
push @info, $dbh->get_info( $GetInfoType{SQL_DBMS_VER} ); |
98
|
0
|
|
|
|
|
|
return join( " ", @info ); |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |