blib/lib/Web/API/Mock/Resource.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 2 / 2 Conditioncond 50.0% 6 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 75.3% 49 / 65 SCAR 21.0
CC
8
Cov
87%
add
7.3
response
2.0
BEGIN
1.0
CRAP 8.1
« blib/lib/Web/API/Mock.pm ↑ Summary Build »
1 package Web::API::Mock::Resource;
2 5 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 our $VERSION = "0.01";
7  
8 use Class::Accessor::Lite (
9 5 new => 1,
10 rw => [ qw/url header body status content_type/ ],
11 5 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub add {
14 20 ▶ my ($self, $args) = @_;
Subroutine add: called CC=7 SCAR=19.9
Pod undocumented
15 20 ▶ my $method = $args->{method} // 'GET';
Condition50%1/2
$args->{"method"} // "GET"
l!l
200
MC/DC0%0/1
$args->{"method"} // "GET"
$args->{"method"}
Truth table50%1/2
A
A= $args->{"method"}
Aresult
11
00
16 20 ▶ my $header = $args->{header} // {};
Condition50%1/2
$args->{"header"} // {}
l!l
200
MC/DC0%0/1
$args->{"header"} // {}
$args->{"header"}
Truth table50%1/2
A
A= $args->{"header"}
Aresult
11
00
17 20 ▶ my $body = $args->{body} // '';
Condition50%1/2
$args->{"body"} // ""
l!l
200
MC/DC0%0/1
$args->{"body"} // ""
$args->{"body"}
Truth table50%1/2
A
A= $args->{"body"}
Aresult
11
00
18 20 ▶ my $status = $args->{status} // 200;
Condition50%1/2
$args->{"status"} // 200
l!l
200
MC/DC0%0/1
$args->{"status"} // 200
$args->{"status"}
Truth table50%1/2
A
A= $args->{"status"}
Aresult
11
00
19 20 ▶ my $content_type = $args->{content_type} // 'text/html';
Condition50%1/2
$args->{"content_type"} // "text/html"
l!l
200
MC/DC0%0/1
$args->{"content_type"} // "text/html"
$args->{"content_type"}
Truth table50%1/2
A
A= $args->{"content_type"}
Aresult
11
00
20  
21 20 ▶ unless ( $self->body ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->body) 18 2 20
22 18 $self->status({});
23 18 $self->content_type({});
24 18 $self->header({});
25 18 $self->body({});
26 }
27  
28 20 $self->status->{$method} = $status;
29 20 $self->content_type->{$method} = $content_type;
30 20 $self->header->{$method} = $header;
31 20 $self->body->{$method} = $body;
32 }
33  
34 sub response {
35 16 ▶ my ($self, $method) = @_;
Subroutine response: called CC=2 SCAR=7.1
Pod undocumented
36 16 ▶ $method //= 'GET';
Condition50%1/2
$method //= "GET"
l!l
160
MC/DC0%0/1
$method //= "GET"
$method
Truth table50%1/2
A
A= $method
Aresult
11
00
37  
38 return {
39 status => $self->status->{$method},
40 content_type => $self->content_type->{$method},
41 header => $self->header->{$method},
42 16 body => $self->body->{$method}
43 }
44  
45 }
46  
47 sub status_404 {
48 return {
49 20 ▶ status => 404,
Subroutine status_404: called CC=1 SCAR=0.0
Pod undocumented
50 content_type => 'text/plain',
51 method => 'GET',
52 header => '',
53 body => '404 Not Found'
54 }
55 }
56  
57 sub status_501 {
58 return {
59 2 ▶ status => 501,
Subroutine status_501: called CC=1 SCAR=0.0
Pod undocumented
60 content_type => 'text/plain',
61 method => 'GET',
62 header => '',
63 body => '501 Not Implemented'
64 }
65 }
66  
67 5 1;
« blib/lib/Web/API/Mock.pm ↑ Summary Build »