File Coverage

blib/lib/Prancer/Session/Store/Database/Driver/Mock.pm
Criterion Covered Total %
statement 30 32 93.7
branch 0 2 0.0
condition n/a
subroutine 9 10 90.0
pod 1 1 100.0
total 40 45 88.8


line stmt bran cond sub pod time code
1             package Prancer::Session::Store::Database::Driver::Mock;
2              
3 2     2   21973 use strict;
  2         5  
  2         82  
4 2     2   8 use warnings FATAL => 'all';
  2         3  
  2         72  
5              
6 2     2   408 use version;
  2         1413  
  2         9  
7             our $VERSION = '1.01';
8              
9 2     2   519 use Prancer::Session::Store::Database::Driver;
  2         4  
  2         58  
10 2     2   9 use parent qw(Prancer::Session::Store::Database::Driver);
  2         3  
  2         11  
11              
12 2     2   126 use Try::Tiny;
  2         3  
  2         91  
13 2     2   8 use Carp;
  2         1  
  2         383  
14              
15             # even though this *should* work automatically, it was not
16             our @CARP_NOT = qw(Prancer Try::Tiny);
17              
18             sub new {
19 3     3 1 4609 my $class = shift;
20 3         38 my $self = bless($class->SUPER::new(@_), $class);
21              
22             try {
23 3     3   626 require DBD::Mock;
24             } catch {
25 0 0   0   0 my $error = (defined($_) ? $_ : "unknown");
26 0         0 croak "could not initialize session handler: could not load DBD::Mock: ${error}";
27 3         27 };
28              
29 3         9904 my $dsn = "dbi:Mock:";
30              
31 3         12 my $params = {
32             'AutoCommit' => 0,
33             'RaiseError' => 1,
34             'PrintError' => 0,
35             };
36              
37             # merge in any additional dsn_params
38 3         20 $params = $self->_merge($params, $self->{'_dsn_extra'});
39              
40 3         9 $self->{'_dsn'} = [ $dsn, undef, undef, $params ];
41 3         7 return $self;
42             }
43              
44             1;