Branch Coverage

blib/lib/PONAPI/Server.pm
Criterion Covered Total %
branch 92 112 82.1


line true false branch
58 25 25 if $ponapi_params->{'__error__'}
97 0 25 $self->{'ponapi.relative_links'} eq 'full' ? :
98 0 25 $self->{'ponapi.relative_links'} eq 'full' ? :
100 18 7 $req->method eq 'GET' ? :
119 0 47 unless grep {$_ eq $method;} 'GET', 'POST', 'PATCH', 'DELETE'
124 3 44 unless defined $type and $type =~ /$qr_member_name_prefix/
127 7 37 if (defined $rel_type) { }
1 36 elsif ($relationships) { }
128 0 7 if $relationships ne 'relationships'
137 1 43 if $def_rel_type and not $rel_type =~ /$qr_member_name_prefix/
141 32 11 if (defined $id) { }
142 2 2 if $method eq 'POST' and $relationships and $def_rel_type
143 21 3 if $method eq 'GET' and not $relationships and not $def_rel_type
144 1 23 if $method eq 'GET' and not $relationships and $def_rel_type
145 2 22 if $method eq 'GET' and $relationships and $def_rel_type
146 0 1 if $method eq 'PATCH' and not $relationships and not $def_rel_type
147 1 0 if $method eq 'PATCH' and $relationships and $def_rel_type
148 2 1 if $method eq 'DELETE' and not $relationships and not $def_rel_type
149 1 2 if $method eq 'DELETE' and $relationships and $def_rel_type
152 2 9 if $method eq 'GET'
153 9 2 if $method eq 'POST'
156 2 41 unless $action
160 30 11 if defined $id
161 7 34 if $def_rel_type
173 1 49 unless $content_type
174 1 48 unless $content_type eq $mt
177 2 46 if (my $accept = $req->headers->header('Accept'))
179 2 0 $_->[1]->type eq $mt ? :
183 1 1 if @jsonapi_accept and not grep({$_->params_are_empty;} @jsonapi_accept)
199 0 18 unless grep {$p eq $_;} 'fields', 'filter', 'page', 'include', 'sort'
203 4 14 if not defined $f and grep {$p eq $_;} 'page', 'fields', 'filter'
207 0 14 if $p eq 'sort' and not $self->{'ponapi.sort_allowed'}
215 4 7 if $p ne 'fields' and exists $query_params->{$k} and not @values
219 3 7 if grep {$p eq $_;} 'fields', 'filter'
222 0 10 if $p eq 'page'
225 7 3 if $p eq 'include'
230 0 10 if $p eq 'sort'
239 21 12 unless $req->content_length > 0
241 0 12 if $req->method eq 'GET'
246 0 11 unless $body and ref $body eq 'HASH' and exists $body->{'data'}
250 1 10 unless not defined $data or ref($data) =~ /^(?:ARRAY|HASH)$/
252 10 0 if defined $data
260 2 8 ref $data eq 'ARRAY' ? :
263 0 10 unless keys %{$r;}
266 0 10 unless $r->{'type'}
267 1 9 unless check_name($r->{'type'})
270 3 6 if ($r->{'attributes'})
271 1 2 unless ref $r->{'attributes'} eq 'HASH'
273 1 1 if grep {not check_name($_);} keys %{$$r{'attributes'};}
277 3 4 if ($r->{'relationships'})
278 1 2 unless ref $r->{'relationships'} eq 'HASH'
281 1 1 unless check_name($k)
286 0 1 if !ref($r->{'relationships'}{$k}{$_}) eq 'HASH' or not exists $r->{'relationships'}{$k}{$_}{'type'}
290 1 0 if not check_name($r->{'relationships'}{$k}{$_}{'type'}) or grep {not check_name($_);} keys %{$$r{'relationships'}{$k}{$_};}
304 50 0 if $self->{'ponapi.send_version_header'}
305 50 0 if (ref $content)