| 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
| |||||||||||
| 27 | 20 | my $mock_class = "Test::Mock::Furl::$real"; | |||||||||
| 28 | 20 | eval "require $mock_class"; ## no critic | |||||||||
| 29 | 20 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | ▶ | warn "error during require $mock_class: $@" if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 36 | } | ||||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 5 | 1; | |||||||||
| 41 | |||||||||||
| 42 | __END__ | ||||||||||