Furl.pm

filter: Statementstmt 92.8% 26 / 28 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 82.9% 34 / 41 CC 6 SCAR 15.7
CC
6
Cov
81%
BEGIN
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
↑ Summary Furl/HTTP.pm »
1 package Test::Mock::Furl;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Test::MockObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 our @EXPORT = qw/
7 $Mock_furl
8 $Mock_furl_http
9 $Mock_furl_req $Mock_furl_request
10 $Mock_furl_res $Mock_furl_resp $Mock_furl_response
11 /;
12  
13 5 our $VERSION = '0.05';
14  
15 5 ▶BEGIN {
Subroutine BEGIN: called CC=6 SCAR=19.9
16 # Don't load the mock classes if the real ones are already loaded
17 5 my $mo = Test::MockObject->new;
18 5 my @mock_classes = (
19 [ 'Furl' => '$Mock_furl' ],
20 [ 'HTTP' => '$Mock_furl_http' ],
21 [ 'Request' => '$Mock_furl_request $Mock_furl_req' ],
22 [ 'Response' => '$Mock_furl_response $Mock_furl_resp $Mock_furl_res' ],
23 );
24 5 for my $c (@mock_classes) {
25 20 my ($real, $imports) = @$c;
26 20 ▶ if (!$mo->check_class_loaded($real)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mo->check_class_loaded($real)) 20 0 20
27 20 my $mock_class = "Test::Mock::Furl::$real";
28 20 eval "require $mock_class"; ## no critic
29 20 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 20 20
30 0 ▶ warn "error during require $mock_class: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
31 0 next;
32 }
33 20 my $import = "$mock_class qw($imports)";
34 20 eval "import $import"; ## no critic
35 20 ▶ warn "error during import $import: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 20 20
36 }
37 }
38 }
39  
40 5 1;
41  
42 __END__
↑ Summary Furl/HTTP.pm »