Test/Form/Widget/Menu/List.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 4 / 4 totaltotal 87.5% 35 / 40 CC 1 SCAR 2.0
CC
1
Cov
89%
size
2.0
gui_type
2.0
BEGIN
1.0
CRAP 1.2
« Test/Form/Widget/Input/File.pm ↑ Summary Test/Form/Widget/Box/Check.pm »
1 package CGI::Test::Form::Widget::Menu::List;
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 ##################################################################
5 # $Id: List.pm 411 2011-09-26 11:19:30Z nohuhu@nohuhu.org $
6 # $Name: cgi-test_0-104_t1 $
7 ##################################################################
8 #
9 # Copyright (c) 2001, Raphael Manfredi
10 #
11 # You may redistribute only under the terms of the Artistic License,
12 # as specified in the README file that comes with the distribution.
13 #
14  
15 14 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #
18 # This class models a FORM scrollable list.
19 #
20  
21 14 ▶use base qw(CGI::Test::Form::Widget::Menu);
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #
24 # %attr
25 #
26 # Defines which HTML attributes we should look at within the node, and how
27 # to translate that into class attributes.
28 #
29  
30 14 my %attr = ('name' => 'name',
31 'size' => 'size',
32 'multiple' => 'multiple',
33 'disabled' => 'is_disabled',
34 );
35  
36 #
37 # ->_init
38 #
39 # Per-widget initialization routine.
40 # Parse HTML node to determine our specific parameters.
41 #
42 sub _init
43 16 ▶{
Subroutine _init: called CC=1 SCAR=0.0
44 16 my $this = shift;
45 16 my ($node) = shift;
46 16 $this->_parse_attr($node, \%attr);
47 16 $this->_parse_options($node);
48 16 return;
49 }
50  
51 #
52 # ->submit_tuples -- redefined
53 #
54 # Returns list of (name => value) tuples that should be part of the
55 # submitted form data.
56 #
57 sub submit_tuples
58 19 ▶{
Subroutine submit_tuples: called CC=1 SCAR=0.0
Pod documented
59 19 my $this = shift;
60  
61 19 return map {$this->name => $_} keys %{$this->selected()};
62 }
63  
64 #
65 # Attribute access
66 #
67  
68 sub size
69 0 ▶{
Subroutine size: not called CC=1 SCAR=6.9
Pod documented
70 0 my $this = shift;
71 0 return $this->{size};
72 }
73  
74 sub gui_type
75 0 ▶{
Subroutine gui_type: not called CC=1 SCAR=6.9
Pod documented
76 0 "scrolling list"
77 }
78  
79 #
80 # Defined predicates
81 #
82  
83 sub is_popup
84 1 ▶{
Subroutine is_popup: called CC=1 SCAR=0.0
Pod documented
85 1 return 0;
86 }
87  
88 14 1;
89  
90 =head1 NAME
91  
92 CGI::Test::Form::Widget::Menu::List - A scrolling list menu
93  
94 =head1 SYNOPSIS
95  
96 # Inherits from CGI::Test::Form::Widget::Menu
97 # $form is a CGI::Test::Form
98  
99 my $action = $form->menu_by_name("action");
100 $action->unselect("allow-gracetime");
101 $action->select("reboot");
102  
103 =head1 DESCRIPTION
104  
105 This class models a scrolling list menu, from which items may be selected
106 and unselected.
107  
108 =head1 INTERFACE
109  
110 The interface is the same as the one described in
111 L<CGI::Test::Form::Widget::Menu>, with the following additional attribute:
112  
113 =over 4
114  
115 =item C<size>
116  
117 The amount of choices displayed.
118  
119 =back
120  
121 =head1 AUTHORS
122  
123 The original author is Raphael Manfredi.
124  
125 Steven Hilton was long time maintainer of this module.
126  
127 Current maintainer is Alexander Tokarev F<E<lt>tokarev@cpan.orgE<gt>>.
128  
129 =head1 SEE ALSO
130  
131 CGI::Test::Form::Widget::Menu(3).
132  
133 =cut
134  
« Test/Form/Widget/Input/File.pm ↑ Summary Test/Form/Widget/Box/Check.pm »