Shopify/Model/Menu/Item.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 87 CC 14 SCAR 37.7
CC
14
Cov
0%
link_url
90.0
link_model_type
42.0
fields
2.0
CRAP 43.3
1 #!/usr/bin/perl
2  
3 use strict;
4 use warnings;
5  
6 use WWW::Shopify;
7  
8 package WWW::Shopify::Model::Menu::Item;
9 use parent "WWW::Shopify::Model::NestedItem";
10  
11 my $fields; sub fields { return $fields; }
12 BEGIN { $fields = {
13 "id" => new WWW::Shopify::Field::Identifier(),
14 "position" => new WWW::Shopify::Field::Int(),
15 "subject" => new WWW::Shopify::Field::String(),
16 "subject_id" => new WWW::Shopify::Field::Int(),
17 "subject_params" => new WWW::Shopify::Field::String(),
18 "title" => new WWW::Shopify::Field::String(),
19 "link_type" => new WWW::Shopify::Field::String::Enum(["collection", "product", "frontpage", "catalog", "page", "blog", "search", "http"])
20 }; }
21  
22 sub creation_minimal { return qw(title link_type); }
23 sub creation_filled { return qw(link_list_id); }
24 sub update_filled { return qw(); }
25  
26 sub link_model_type {
27 return ('WWW::Shopify::Model::CustomCollection', 'WWW::Shopify::Model::SmartCollection') if $_[0]->link_type eq 'collection';
28 return 'WWW::Shopify::Model::Product' if $_[0]->link_type eq 'product';
29 return 'WWW::Shopify::Model::Page' if $_[0]->link_type eq 'page';
30 return 'WWW::Shopify::Model::Blog' if $_[0]->link_type eq 'blog';
31 return () if wantarray;
32 return undef;
33 }
34  
35 sub link_url {
36 return '/search' if $_[0]->link_type eq "search";
37 return '/' if $_[0]->link_type eq "frontpage";
38 return '/collections/all' if $_[0]->link_type eq "catalog";
39 return $_[0]->subject if $_[0]->link_type eq "http";
40 return '/collections/' . $_[0]->subject if $_[0]->link_type eq 'collection';
41 return '/products/' . $_[0]->subject if $_[0]->link_type eq 'product';
42 return '/pages/' . $_[0]->subject if $_[0]->link_type eq 'page';
43 return '/blogs/' . $_[0]->subject if $_[0]->link_type eq 'blogs';
44 return undef;
45 }
46  
47 sub needs_login { return 1; }
48  
49 eval(__PACKAGE__->generate_accessors); die $@ if $@;
50  
51 1;