Database/Driver/Mock.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 83.6% 46 / 55 CC 4 SCAR 8.4
CC
4
Cov
84%
__ANON__
6.0
new
3.4
BEGIN
1.0
CRAP 2.3
« Database.pm ↑ Summary
1 package Prancer::Plugin::Database::Driver::Mock;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 our $VERSION = '1.04';
8  
9 2 ▶use Prancer::Plugin::Database::Driver;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use parent qw(Prancer::Plugin::Database::Driver);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # even though this *should* work automatically, it was not
16 2 our @CARP_NOT = qw(Prancer Try::Tiny);
17  
18 7 ▶sub new {
Subroutine new: called CC=3 SCAR=12.2
Pod undocumented
19 7 my $class = shift;
20 7 my $self = bless($class->SUPER::new(@_), $class);
21  
22 7 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 7 require DBD::Mock;
24 0 ▶ } catch {
Subroutine __ANON__: not called CC=2 SCAR=17.9
25 0 ▶ my $error = (defined($_) ? $_ : "unknown");
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
26 0 croak "could not initialize database connection '${\$self->{'_connection'}}': could not load DBD::Mock: ${error}";
27 7 };
28  
29 7 my $database = $self->{'_database'};
30  
31 # if autocommit isn't configured then enable it by default
32 7 ▶ my $autocommit = (defined($self->{'_autocommit'}) ? ($self->{'_autocommit'} =~ /^(1|true|yes)$/ix ? 1 : 0) : 1);
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'_autocommit'} ? : 7 0 7
$self->{'_autocommit'} =~ /^(1|true|yes)$/xi ? : 0 7 7
33  
34 7 my $dsn = "dbi:Mock:";
35  
36 7 my $params = {
37 'AutoCommit' => $autocommit,
38 'RaiseError' => 1,
39 'PrintError' => 0,
40 };
41  
42 # merge in any additional dsn_params
43 7 $params = $self->_merge($params, $self->{'_dsn_extra'});
44  
45 7 $self->{'_dsn'} = [ $dsn, undef, undef, $params ];
46 7 return $self;
47 }
48  
49 2 1;
« Database.pm ↑ Summary