Component/Test/BabelObjects/Test.pm untested

filter: Statementstmt 0.0% 0 / 68 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 102 CC 4 SCAR 14.8
CC
4
Cov
0%
AUTOLOAD
12.0
getValue
6.0
new
2.0
CRAP 4.4
1 #/*====================================================================
2 # * Babel Objects, Version 1.0
3 # * ====================================================================
4 # *
5 # * Copyright (c) 2000 The Babel Objects Network. All rights reserved.
6 # *
7 # * This source file is subject to version 1.1 of The Babel Objects
8 # * License, that is bundled with this package in the file LICENSE,
9 # * and is available through the world wide web at :
10 # *
11 # * http://www.BabelObjects.Org/law/license/1.1.txt
12 # *
13 # * If you did not receive a copy of the Babel Objects license and are
14 # * unable to obtain it through the world wide web, please send a note
15 # * to license@BabelObjects.Org so we can mail you a copy immediately.
16 # *
17 # * --------------------------------------------------------------------
18 # *
19 # * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
20 # * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 # * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 # * DISCLAIMED. IN NO EVENT SHALL THE BABEL OBJECTS NETWORK OR
23 # * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 # * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 # * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 # * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # * SUCH DAMAGE.
31 # *
32 # * ====================================================================
33 # *
34 # * This software consists of voluntary contributions made by many
35 # * individuals on behalf of The Babel Objects Network. For more
36 # * information on The Babel Objects Network, please see
37 # * <http://www.BabelObjects.org/>.
38 # *
39 # */
40  
41 package BabelObjects::Component::Test::BabelObjects::Test;
42  
43 use Carp;
44 use strict;
45  
46 use BabelObjects::Util::Dvlpt::Log;
47  
48 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD);
49  
50 require Exporter;
51 require AutoLoader;
52  
53 @ISA = qw(Exporter AutoLoader);
54 # Items to export into callers namespace by default. Note: do not export
55 # names by default without a very good reason. Use EXPORT_OK instead.
56 # Do not simply export all your public functions/methods/constants.
57 @EXPORT = qw(
58 );
59 $VERSION = '1.00';
60  
61 my $aLog;
62  
63 my %fields = (
64 runData => undef
65 );
66
67 sub new {
68 my $proto = shift;
69 my $args = shift;
70
71 print STDERR "TEST ARGS = $args\n";
72  
73 my $class = ref($proto) || $proto;
74
75 my $self = {
76 _permitted => \%fields,
77 %fields,
78 };
79
80 bless ($self, $class);
81
82 my %parameters = %$args;
83  
84 $aLog = new BabelObjects::Util::Dvlpt::Log();
85 $aLog->log("\n--BabelObjects::Component::Test::BabelObjects::Test--");
86  
87 foreach (keys %parameters) {
88 # the following lines are useful to verify argument values
89 $aLog->log("$_ = ".$parameters{$_});
90 $aLog->log("$_ = ".$self->$_);
91 $self->$_($parameters{$_});
92 }
93  
94 return $self;
95 }
96
97 sub t_test {
98 my $self = shift;
99  
100 return "OK";
101 }
102  
103 sub getBoInfo {
104 my $self = shift;
105  
106 # this method is a little silly because the information
107 # is redundant between here and xml file
108  
109 my %attributes = ();
110  
111 # BO Tags that can be called in bo page
112  
113 $attributes{"hello"} = "Hello";
114 $attributes{"world"} = "World";
115  
116 # BO Transitions that are called with T input field
117 # Please note that "t_" is automatically added
118 # do not put "t_" in your T var
119  
120 $attributes{"t_test"} = "t_test";
121
122 return %attributes;
123 }
124
125 sub getHello {
126 return "Hello";
127 }
128  
129 sub getWorld {
130 print "World";
131 }
132  
133 sub getValue {
134 my $self = shift;
135 my $key = shift;
136 my $x;
137
138 my $doc = $self->parameters;
139 my $context = $self->context;
140
141 foreach $x ($doc->$context->parameter) {
142 my $name = $x->name->getString;
143 if (lc($name) eq $key) {
144 return $x->value->getString;
145 }
146 }
147
148 return "PB";
149 }
150  
151 sub AUTOLOAD {
152 my $self = shift;
153 my $type = ref($self) or croak "$self is not an object";
154
155 my $name = $AUTOLOAD;
156 $name =~ s/.*://; # strip fully-qualified portion
157
158 unless (exists $self->{_permitted}->{$name} ) {
159 # croak "Can't access `$name' field in class $type";
160 # On intercepte ici les erreurs liées aux tentatives d'appel
161 # des méthodes inexistantes
162 $aLog->log("AUTOLOAD : $self = $AUTOLOAD");
163 return $AUTOLOAD;
164 }
165
166 if (@_) {
167 return $self->{$name} = shift;
168 } else {
169 return $self->{$name};
170 }
171 }
172
173 1;
174 __END__