ECommerce/Plugin/Basket/View.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 94 CC 3 SCAR 13.5
CC
3
Cov
0%
countries_unselected
12.0
template_path
2.0
http_get
2.0
CRAP 3.9
1 # -------------------------------------------------------------------------------------
2 # flo::plugin::Shop::Basket::View
3 # -------------------------------------------------------------------------------------
4 # Author : Jean-Michel Hiver <jhiver@mkdoc.com>.
5 # Copyright : (c) MKDoc Holdings Ltd, 2003
6 #
7 # Provides common methods which are used to view the basket,
8 # add an item to the basket, or delete an item from the basket.
9 # -------------------------------------------------------------------------------------
10 package flo::plugin::Shop::Basket::View;
11 use warnings;
12 use flo::Standard;
13 use flo::plugin::Shop::Basket::Help;
14 use MKDoc::Session;
15 use MKDoc::ECommerce::Item;
16 use MKDoc::ECommerce::Basket;
17 use Geography::Countries;
18  
19 use base qw /flo::plugin::Shop::Basket/;
20  
21  
22 sub template_path
23 {
24 my $self = shift;
25 return 'shop/basket/view';
26 }
27  
28  
29 ##
30 # $self->http_get;
31 # ----------------
32 # Displays the form which lets the editor choose which audiences
33 # the current document relates to.
34 ##
35 sub http_get
36 {
37 my $self = shift;
38 my $cgi = flo::Standard::cgi();
39  
40 # if there is no session present, redirect to a help
41 # page about cookies, user accounts and stuff
42 my $session = $self->session() || do {
43 my $help_p = new flo::plugin::Shop::Basket::Help();
44 print $cgi->redirect ($help_p->uri());
45 return 'TERMINATE';
46 };
47  
48 $self->render_http (
49 self => $self,
50 __input__ => 'XML',
51 __output__ => 'XHTML',
52 );
53
54 return 'TERMINATE';
55 }
56  
57  
58 sub get_rules
59 {
60 my $self = shift;
61 my $session = $self->session() || return;
62 my $country = $session->{country};
63 my $basket = $session->{basket};
64 return new MKDoc::ECommerce::Rules ( country => $country, basket => $basket );
65 }
66  
67  
68 sub session
69 {
70 return MKDoc::Session->load();
71 }
72  
73  
74 sub countries_selected
75 {
76 my $self = shift || return;
77 my $session = $self->session() || return 'United Kingdom';
78 my $country = $session->{country} || return 'United Kingdom';
79 return $country;
80 }
81  
82  
83 sub countries_unselected
84 {
85 my $self = shift;
86 my $selected = $self->countries_selected() || 'this will never match';
87 my @countries = map { $_ eq $selected ? () : $_ } Geography::Countries::countries();
88 return wantarray ? @countries : \@countries;
89 }
90  
91  
92 1;
93  
94  
95 __END__