| 1 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package HTML::Tested::Test::Request::Upload; | ||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use base 'Class::Accessor'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 7 | __PACKAGE__->mk_accessors(qw(name filename fh size)); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package HTML::Tested::Test::Request; | ||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use base 'Class::Accessor'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use HTML::Tested::Seal; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use File::Basename qw(basename); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 7 | __PACKAGE__->mk_accessors(qw(_param _pnotes _uploads _dir_config uri)); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | sub hostname { return "some.host"; } | ||||||||||||||||||||||||||
|
Subroutine
hostname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub server { return shift(); } | ||||||||||||||||||||||||||
|
Subroutine
server: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | sub port { return 80; } | ||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub server_root_relative { | ||||||||||||||||||||||||||
|
Subroutine
server_root_relative: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | return $_[1]; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub body_status { return 'Success'; } | ||||||||||||||||||||||||||
|
Subroutine
body_status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 45 | ▶ | sub param { | ||||||||||||||||||||||||||
|
Subroutine
param: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 45 | my ($self, $name, $val) = @_; | |||||||||||||||||||||||||||
| 28 | 45 | ▶ | return $self->_param unless (wantarray || $name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
wantarray or $name
MC/DC100%2/2
wantarray or $name
wantarray
$name
Truth table100%3/3
A or B
A= wantarrayB= $name
| |||||||||||||||||||||||||||||
| 29 | 43 | ▶ | $self->_param({}) unless $self->_param; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 43 | ▶ | $self->_param->{$name} = $val if @_ == 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 43 | ▶ | return $self->_param->{$name} if ($name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 6 | ▶ | return keys %{ $self->_param || {} }; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->_param || {}
MC/DC0%0/1
$self->_param || {}
$self->_param
Truth table50%1/2
A
A= $self->_param
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub dir_config { | ||||||||||||||||||||||||||
|
Subroutine
dir_config: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($self, $name, $val) = @_; | |||||||||||||||||||||||||||
| 37 | 0 | my $dc = $self->_dir_config; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | if (!$dc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | $dc = {}; | |||||||||||||||||||||||||||
| 40 | 0 | $self->_dir_config($dc); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return $dc->{$name} if (@_ < 3); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $dc->{$name} = $val if defined($val); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | delete $dc->{$name} if !defined($val); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head2 $object->set_params($paramref) | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | Sets param values according to C<$paramref> hash. Clears old params first. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Parameter names starting with C<HT_SEALED_> are encrypted and C<HT_SEALED_> | ||||||||||||||||||||||||||||
| 52 | prefix is removed. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||
| 55 | 3 | ▶ | sub set_params { | ||||||||||||||||||||||||||
|
Subroutine
set_params: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 3 | my ($self, $p) = @_; | |||||||||||||||||||||||||||
| 57 | 3 | $self->_param({}); | |||||||||||||||||||||||||||
| 58 | 3 | ▶ | while (my ($n, $v) = each %$p) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 4 | ▶ | $v = HTML::Tested::Seal->instance->encrypt($v) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | if ($n =~ s/^HT_SEALED_//); | ||||||||||||||||||||||||||||
| 61 | 4 | $self->param($n, $v); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 3 | ▶ | sub parse_url { | ||||||||||||||||||||||||||
|
Subroutine
parse_url: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 3 | my ($self, $url) = @_; | |||||||||||||||||||||||||||
| 67 | 3 | my ($arg_str) = ($url =~ /\?(.+)/); | |||||||||||||||||||||||||||
| 68 | 3 | ▶ | return unless $arg_str; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 3 | my @nvs = split('&', $arg_str); | |||||||||||||||||||||||||||
| 70 | my %res = map { | ||||||||||||||||||||||||||||
| 71 | 3 | my @a = split('=', $_); | |||||||||||||||||||||||||||
| 72 | 8 | ▶ | ($a[0], ($a[1] || '')); | ||||||||||||||||||||||||||
|
Condition100%2/2
$a[1] || ''
MC/DC100%1/1
$a[1] || ''
$a[1]
Truth table100%2/2
A
A= $a[1]
| |||||||||||||||||||||||||||||
| 73 | } @nvs; | ||||||||||||||||||||||||||||
| 74 | 3 | $self->_param(\%res); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub pnotes { | ||||||||||||||||||||||||||
|
Subroutine
pnotes: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | my ($self, $name, $val) = @_; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->_pnotes({}) unless $self->_pnotes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return $self->_pnotes->{$name} unless scalar(@_) > 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $self->_pnotes->{$name} = $val; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 6 | ▶ | sub add_upload { | ||||||||||||||||||||||||||
|
Subroutine
add_upload: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | 6 | my ($self, $n, $v) = @_; | |||||||||||||||||||||||||||
| 86 | 6 | ▶ | $self->_uploads([]) unless $self->_uploads; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 6 | ▶ | open(my $fh, $v) or die "Unable to open $v"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 6 | push @{ $self->_uploads }, HTML::Tested::Test::Request::Upload->new({ | |||||||||||||||||||||||||||
| 89 | name => $n, filename => $v , fh => $fh, size => -s $v }); | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 20 | ▶ | sub upload { | ||||||||||||||||||||||||||
|
Subroutine
upload: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 20 | my ($self, $n) = @_; | |||||||||||||||||||||||||||
| 94 | 20 | ▶ | my $ups = $self->_uploads || []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->_uploads || []
MC/DC0%0/1
$self->_uploads || []
$self->_uploads
Truth table50%1/2
A
A= $self->_uploads
| |||||||||||||||||||||||||||||
| 95 | 20 | ▶ | return $n ? (grep { $_->name eq $n } @$ups)[0] : map { $_->name } @$ups; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 99 | 1 | return Dumper(shift()); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 7 | 1; | |||||||||||||||||||||||||||