Branch Coverage

blib/lib/PONAPI/Server.pm
Criterion Covered Total %
branch 110 144 76.3


line true false branch
63 25 25 unless (eval { do { $ponapi_params = $self->_ponapi_params($req); 1 } })
68 0 50 if $ponapi_params->{'__options__'}
71 25 25 if $ponapi_params->{'__error__'}
96 89 52 if $req->method =~ /^(?:GET|HEAD)$/
116 0 25 $self->{'ponapi.relative_links'} eq 'full' ? :
117 0 25 $self->{'ponapi.relative_links'} eq 'full' ? :
119 18 7 _is_get_like($req) ? :
138 0 46 unless grep {$_ eq $method;} 'GET', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'
143 3 43 unless defined $type and $type =~ /$qr_member_name_prefix/
146 7 36 if (defined $rel_type) { }
1 35 elsif ($relationships) { }
147 0 7 if $relationships ne 'relationships'
156 1 42 if $def_rel_type and not $rel_type =~ /$qr_member_name_prefix/
160 31 11 if (defined $id) { }
161 2 2 if $method eq 'POST' and $relationships and $def_rel_type
162 20 3 if _is_get_like($req) and not $relationships and not $def_rel_type
163 1 22 if _is_get_like($req) and not $relationships and $def_rel_type
164 2 21 if _is_get_like($req) and $relationships and $def_rel_type
165 0 1 if $method eq 'PATCH' and not $relationships and not $def_rel_type
166 1 0 if $method eq 'PATCH' and $relationships and $def_rel_type
167 2 1 if $method eq 'DELETE' and not $relationships and not $def_rel_type
168 1 2 if $method eq 'DELETE' and $relationships and $def_rel_type
171 2 9 if _is_get_like($req)
172 9 2 if $method eq 'POST'
175 0 42 if ($method eq 'OPTIONS')
177 0 0 if (defined $id) { }
178 0 0 unless $def_rel_type
186 2 40 unless $action
190 29 11 if defined $id
191 7 33 if $def_rel_type
198 0 50 if $req->method eq 'OPTIONS'
205 13 37 if ($req->content_length)
206 13 0 if (my $content_type = $req->headers->header('Content-Type')) { }
207 0 13 unless $content_type eq $mt
215 35 15 if (my $accept = $req->headers->header('Accept'))
219 34 1 $_->[1]->type eq $mt ? :
222 34 1 if (@jsonapi_accept)
224 1 33 unless grep {$_->params_are_empty;} @jsonapi_accept
230 3 46 unless $has_mediatype
246 0 17 unless defined $p
250 0 17 unless grep {$p eq $_;} 'fields', 'filter', 'page', 'include', 'sort'
254 4 13 if not defined $f and grep {$p eq $_;} 'page', 'fields', 'filter'
258 0 13 if $p eq 'sort' and not $self->{'ponapi.sort_allowed'}
261 0 11 $unesacpe_values ? :
266 3 10 if $p ne 'fields' and not @values
270 3 7 if grep {$p eq $_;} 'fields', 'filter'
273 0 10 if $p eq 'page'
276 7 3 if $p eq 'include'
281 0 10 if $p eq 'sort'
290 21 12 unless $req->content_length and $req->content_length > 0
292 0 12 if _is_get_like($req)
297 0 11 unless $body and ref $body eq 'HASH' and exists $body->{'data'}
301 1 10 if defined $data and not ref($data) =~ /^(?:ARRAY|HASH)$/
303 10 0 if defined $data
311 2 8 ref $data eq 'ARRAY' ? :
314 0 10 unless keys %{$r;}
317 0 10 unless $r->{'type'}
318 1 9 unless check_name($r->{'type'})
321 3 6 if (exists $r->{'attributes'})
322 1 2 unless ref $r->{'attributes'} eq 'HASH'
324 1 1 if grep {not check_name($_);} keys %{$$r{'attributes'};}
328 3 4 if (exists $r->{'relationships'})
329 1 2 unless ref $r->{'relationships'} eq 'HASH'
332 1 1 unless check_name($k)
335 0 1 ref($rel || '') eq 'ARRAY' ? :
337 0 1 unless defined $relationship
341 1 0 if exists $relationship->{'data'}
344 0 1 unless ref $relationship eq 'HASH' and exists $relationship->{'type'}
348 1 0 if not check_name($relationship->{'type'}) or grep {not check_name($_);} keys %$relationship
361 50 0 if $self->{'ponapi.send_version_header'}
363 50 0 if (ref $content)
367 50 0 unless $is_head