File Coverage

blib/lib/SimpleMock/Mocks/DBI.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package SimpleMock::Mocks::DBI;
2 4     4   22 use strict;
  4         24  
  4         134  
3 4     4   12 use warnings;
  4         5  
  4         169  
4              
5 4     4   15 no warnings 'redefine';
  4         5  
  4         459  
6              
7             our $VERSION = '0.01';
8            
9             my $orig_connect = \&DBI::connect;
10            
11             # force DBI connect to use dbd:SimpleMock
12             *DBI::connect = sub {
13 10     10   2741 my ($class, undef, undef, undef, $attr) = @_;
14 10         44 return $orig_connect->($class, 'dbi:SimpleMock:', undef, undef, $attr);
15             };
16              
17             1;
18              
19             =head1 NAME
20              
21             SimpleMock::Mocks::DBI - Mock DBI module for testing
22              
23             =head1 DESCRIPTION
24              
25             This module mocks the connect method of the DBI module to force it to use a
26             dbi:SimpleMock database connection.
27              
28             =cut