| 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"
MC/DC0%0/1
$args->{"method"} // "GET"
$args->{"method"}
Truth table50%1/2
A
A= $args->{"method"}
| |||||||||||||
| 16 | 20 | ▶ | my $header = $args->{header} // {}; | ||||||||||
|
Condition50%1/2
$args->{"header"} // {}
MC/DC0%0/1
$args->{"header"} // {}
$args->{"header"}
Truth table50%1/2
A
A= $args->{"header"}
| |||||||||||||
| 17 | 20 | ▶ | my $body = $args->{body} // ''; | ||||||||||
|
Condition50%1/2
$args->{"body"} // ""
MC/DC0%0/1
$args->{"body"} // ""
$args->{"body"}
Truth table50%1/2
A
A= $args->{"body"}
| |||||||||||||
| 18 | 20 | ▶ | my $status = $args->{status} // 200; | ||||||||||
|
Condition50%1/2
$args->{"status"} // 200
MC/DC0%0/1
$args->{"status"} // 200
$args->{"status"}
Truth table50%1/2
A
A= $args->{"status"}
| |||||||||||||
| 19 | 20 | ▶ | my $content_type = $args->{content_type} // 'text/html'; | ||||||||||
|
Condition50%1/2
$args->{"content_type"} // "text/html"
MC/DC0%0/1
$args->{"content_type"} // "text/html"
$args->{"content_type"}
Truth table50%1/2
A
A= $args->{"content_type"}
| |||||||||||||
| 20 | |||||||||||||
| 21 | 20 | ▶ | unless ( $self->body ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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"
MC/DC0%0/1
$method //= "GET"
$method
Truth table50%1/2
A
A= $method
| |||||||||||||
| 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; | |||||||||||