Mock/st.pm

filter: Statementstmt 87.8% 195 / 222 Branchbran 85.4% 106 / 124 Conditioncond 65.0% 13 / 20 MC/DCmcdc 45.4% 5 / 11 Subroutinesub 100% 19 / 19 Podpod 0.0% 0 / 14 totaltotal 82.4% 338 / 410 CC 76 SCAR 28.6
CC
76
Cov
86%
FETCH
33.2
fetchall_hashref
21.1
execute
15.1
CRAP 17.4
« Mock/db.pm ↑ Summary Mock/Session.pm »
1 package DBD::Mock::st;
2  
3 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 41 our $imp_data_size = 0;
7  
8 13 ▶sub bind_col {
Subroutine bind_col: called CC=1 SCAR=0.0
Pod undocumented
9 13 my ( $sth, $param_num, $ref, $attr ) = @_;
10  
11 13 my $tracker = $sth->FETCH('mock_my_history');
12 13 $tracker->bind_col( $param_num, $ref );
13 13 return 1;
14 }
15  
16 14 ▶sub bind_param {
Subroutine bind_param: called CC=1 SCAR=0.0
Pod undocumented
17 14 my ( $sth, $param_num, $val, $attr ) = @_;
18 14 my $tracker = $sth->FETCH('mock_my_history');
19 14 $tracker->bound_param( $param_num, $val, $attr );
20 14 return 1;
21 }
22  
23 2 ▶sub bind_param_array {
Subroutine bind_param_array: called CC=1 SCAR=0.0
Pod undocumented
24 2 bind_param(@_);
25 }
26  
27 2 ▶sub bind_param_inout {
Subroutine bind_param_inout: called CC=3 SCAR=11.2
Pod undocumented
28 2 my ( $sth, $param_num, $val, $max_len ) = @_;
29  
30 # check that $val is a scalar ref
31 ( UNIVERSAL::isa( $val, 'SCALAR' ) )
32 || $sth->{Database}
33 2 ▶ ->set_err( 1, "need a scalar ref to bind_param_inout, not $val" );
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($val, "SCALAR") or $sth->{"Database"}->set_err(1, "need a scalar ref to bind_param_inout, not $val") 2 0 2
34  
35 # check for positive $max_len
36 ( $max_len > 0 )
37 || $sth->{Database}
38 2 ▶ ->set_err( 1, "need to specify a maximum length to bind_param_inout" );
Branch: 1 branch
BranchTrueFalseTotal
$max_len > 0 or $sth->{"Database"}->set_err(1, "need to specify a maximum length to bind_param_inout") 2 0 2
39 2 my $tracker = $sth->FETCH('mock_my_history');
40 2 $tracker->bound_param( $param_num, $val );
41 2 return 1;
42 }
43  
44 1 ▶sub execute_array {
Subroutine execute_array: called CC=3 SCAR=11.0
Pod undocumented
45 1 my ( $sth, $attr, @bind_values ) = @_;
46  
47 # no bind values means we're relying on prior calls to bind_param_array()
48 # for our data
49 1 my $tracker = $sth->FETCH('mock_my_history');
50 # don't use a reference; there's some magic attached to it somewhere
51 # so make it a lovely, simple array as soon as possible
52 1 my @bound = @{ $tracker->bound_params() };
53 1 foreach my $p (@bound) {
54 2 my $result = $sth->execute( @$p );
55 # store the result from execute() if ArrayTupleStatus attribute is
56 # passed
57 2 push @{ $attr->{ArrayTupleStatus} }, $result
58 2 ▶ if (exists $attr->{ArrayTupleStatus});
Branch: 1 branch
BranchTrueFalseTotal
if exists $attr->{"ArrayTupleStatus"} 2 0 2
59 }
60  
61 # TODO: the docs say:
62 # When called in scalar context the execute_array() method returns the
63 # number of tuples executed, or undef if an error occurred. Like
64 # execute(), a successful execute_array() always returns true regardless
65 # of the number of tuples executed, even if it's zero. If there were any
66 # errors the ArrayTupleStatus array can be used to discover which tuples
67 # failed and with what errors.
68 # When called in list context the execute_array() method returns two
69 # scalars; $tuples is the same as calling execute_array() in scalar
70 # context and $rows is the number of rows affected for each tuple, if
71 # available or -1 if the driver cannot determine this.
72 # We have glossed over this...
73 1 return scalar @bound;
74 }
75  
76 163 ▶sub execute {
Subroutine execute: called CC=15 SCAR=27.1
Pod undocumented
77 163 my ( $sth, @params ) = @_;
78 163 my $dbh = $sth->{Database};
79  
80 163 ▶ unless ( $dbh->{mock_can_connect} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_connect"}) 1 162 163
81 1 $dbh->set_err( 1, "No connection present" );
82 0 return 0;
83 }
84 162 ▶ unless ( $dbh->{mock_can_execute} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_execute"}) 2 160 162
85 2 $dbh->set_err( 1, "Cannot execute" );
86 0 return 0;
87 }
88 160 ▶ $dbh->{mock_can_execute}++ if $dbh->{mock_can_execute} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $dbh->{"mock_can_execute"} < 0 3 157 160
89  
90 160 my $tracker = $sth->FETCH('mock_my_history');
91  
92 160 ▶ if ( $tracker->has_failure() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tracker->has_failure) 3 157 160
93 3 $dbh->set_err( $tracker->get_failure() );
94 0 return 0;
95 }
96  
97 157 ▶ if (@params) {
Branch: 1 branch
BranchTrueFalseTotal
if (@params) 57 100 157
98 57 $tracker->bind_params(@params);
99 }
100  
101 157 ▶ if ( my $session = $dbh->{mock_session} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $session = $dbh->{"mock_session"}) 59 98 157
102 59 eval {
103 59 my $state = $session->current_state;
104 59 $session->verify_statement( $sth->{Statement});
105 $session->verify_bound_params( $tracker->bound_params(),
106 53 { bound_arrays => $dbh->{mock_bound_array_support} } );
107  
108 # Load a copy of the results to return (minus the field
109 # names) into the tracker
110 43 my @results = @{ $state->{results} };
111 43 shift @results;
112 43 $tracker->{return_data} = \@results;
113 };
114 59 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 16 43 59
115 16 my $session_error = $@;
116 16 chomp $session_error;
117 16 $sth->set_err( 1, "Session Error: ${session_error}" );
118 16 return;
119 }
120 }
121  
122 141 $tracker->mark_executed;
123 140 my $fields = $tracker->fields;
124 140 ▶ $sth->STORE( NUM_OF_FIELDS => scalar @{ $fields ? $fields : [] } );
Branch: 1 branch
BranchTrueFalseTotal
$fields ? : 140 0 140
125 140 $sth->STORE( NAME => $fields );
126  
127 140 $sth->STORE( NUM_OF_PARAMS => $tracker->num_params );
128  
129 # handle INSERT statements and the mock_last_insert_ids
130 # We should only increment these things after the last successful INSERT.
131 # -RobK, 2007-10-12
132 #use Data::Dumper;warn Dumper $dbh->{mock_last_insert_ids};
133  
134 140 ▶ if ( $dbh->{Statement} =~ /^\s*?insert(?:\s+ignore)?\s+into\s+(\S+)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbh->{"Statement"} =~ /^\s*?insert(?:\s+ignore)?\s+into\s+(\S+)/i) 23 117 140
135 23 ▶ if ( $tracker->{last_insert_id} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tracker->{'last_insert_id'}) { } 1 22 23
elsif ($dbh->{'mock_last_insert_ids'} and exists $dbh->{'mock_last_insert_ids'}{$1}) { } 7 15 22
136 1 $dbh->{mock_last_insert_id} = $tracker->{last_insert_id};
137  
138 ▶ } elsif ( $dbh->{mock_last_insert_ids}
Condition66%2/3
$dbh->{"mock_last_insert_ids"} and exists $dbh->{"mock_last_insert_ids"}{$1}
!ll&&!rl&&r
1507
MC/DC50%1/2
$dbh->{"mock_last_insert_ids"} and exists $dbh->{"mock_last_insert_ids"}{$1}
$dbh->{"mock_last_insert_ids"} exists $dbh->{"mock_last_insert_ids"}{$1}
Truth table66%2/3
A and B
A= $dbh->{"mock_last_insert_ids"}B= exists $dbh->{"mock_last_insert_ids"}{$1}
ABresult
0X0
100
111
139 && exists $dbh->{mock_last_insert_ids}{$1} )
140 {
141 7 $dbh->{mock_last_insert_id} = $dbh->{mock_last_insert_ids}{$1}++;
142 }
143 else {
144 15 $dbh->{mock_last_insert_id}++;
145 }
146 }
147  
148 #warn "$dbh->{mock_last_insert_id}\n";
149  
150 # always return 0E0 for Selects
151 140 ▶ if ( $dbh->{Statement} =~ /^\s*?select/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbh->{"Statement"} =~ /^\s*?select/i) 104 36 140
152 104 return '0E0';
153 }
154 36 ▶ return ( $sth->rows() || '0E0' );
Condition100%2/2
$sth->rows || '0E0'
l!l
333
MC/DC100%1/1
$sth->rows || '0E0'
$sth->rows
Truth table100%2/2
A
A= $sth->rows
Aresult
11
00
155 }
156  
157 149 ▶sub fetch {
Subroutine fetch: called CC=7 SCAR=19.5
Pod undocumented
158 149 my ($sth) = @_;
159 149 my $dbh = $sth->{Database};
160 149 ▶ unless ( $dbh->{mock_can_connect} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_connect"}) 1 148 149
161 1 $dbh->set_err( 1, "No connection present" );
162 0 return;
163 }
164 148 ▶ unless ( $dbh->{mock_can_fetch} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_fetch"}) 3 145 148
165 3 $dbh->set_err( 1, "Cannot fetch" );
166 0 return;
167 }
168 145 ▶ $dbh->{mock_can_fetch}++ if $dbh->{mock_can_fetch} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $dbh->{"mock_can_fetch"} < 0 4 141 145
169  
170 145 my $tracker = $sth->FETCH('mock_my_history');
171  
172 145 ▶ my $record = $tracker->next_record
Branch: 1 branch
BranchTrueFalseTotal
my $record = $tracker->next_record or return 126 19 145
173 or return;
174  
175 126 ▶ if ( my @cols = $tracker->bind_cols() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@cols) = $tracker->bind_cols) 6 120 126
176 6 for my $i ( grep { ref $cols[$_] } 0 .. $#cols ) {
177 14 ${ $cols[$i] } = $record->[$i];
178 }
179 }
180  
181 126 return $record;
182 }
183  
184 36 ▶sub fetchrow_array {
Subroutine fetchrow_array: called CC=2 SCAR=6.9
Pod undocumented
185 36 my ($sth) = @_;
186 36 my $row = $sth->DBD::Mock::st::fetch();
187 35 ▶ return unless ref($row) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $row eq "ARRAY" 2 33 35
188 33 return @{$row};
189 }
190  
191 87 ▶sub fetchrow_arrayref {
Subroutine fetchrow_arrayref: called CC=1 SCAR=0.0
Pod undocumented
192 87 my ($sth) = @_;
193 87 return $sth->DBD::Mock::st::fetch();
194 }
195  
196 10 ▶sub fetchrow_hashref {
Subroutine fetchrow_hashref: called CC=6 SCAR=18.2
Pod undocumented
197 10 my ( $sth, $name ) = @_;
198 10 my $dbh = $sth->{Database};
199  
200 # handle any errors since we are grabbing
201 # from the tracker directly
202 10 ▶ unless ( $dbh->{mock_can_connect} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_connect"}) 0 10 10
203 0 $dbh->set_err( 1, "No connection present" );
204 0 return;
205 }
206 10 ▶ unless ( $dbh->{mock_can_fetch} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_fetch"}) 1 9 10
207 1 $dbh->set_err( 1, "Cannot fetch" );
208 0 return;
209 }
210 9 ▶ $dbh->{mock_can_fetch}++ if $dbh->{mock_can_fetch} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $dbh->{"mock_can_fetch"} < 0 1 8 9
211  
212 # first handle the $name, it will default to NAME
213 9 ▶ $name ||= 'NAME';
Condition50%1/2
$name ||= "NAME"
l!l
09
MC/DC0%0/1
$name ||= "NAME"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
214  
215 # then fetch the names from the $sth (per DBI spec)
216 9 my $fields = $sth->FETCH($name);
217  
218 # now check the tracker ...
219 9 my $tracker = $sth->FETCH('mock_my_history');
220  
221 # and collect the results
222 9 ▶ if ( my $record = $tracker->next_record() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $record = $tracker->next_record) 6 3 9
223 6 my @values = @{$record};
224 6 return { map { $_ => shift(@values) } @{$fields} };
225 }
226  
227 3 return undef;
228 }
229  
230 #XXX Isn't this supposed to return an array of hashrefs? -RobK, 2007-10-15
231 5 ▶sub fetchall_hashref {
Subroutine fetchall_hashref: called CC=15 SCAR=30.5
Pod undocumented
232 5 my ( $sth, $keyfield ) = @_;
233 5 my $dbh = $sth->{Database};
234  
235 # handle any errors since we are grabbing
236 # from the tracker directly
237 5 ▶ unless ( $dbh->{mock_can_connect} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_connect"}) 0 5 5
238 0 $dbh->set_err( 1, "No connection present" );
239 0 return;
240 }
241 5 ▶ unless ( $dbh->{mock_can_fetch} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"mock_can_fetch"}) 0 5 5
242 0 $dbh->set_err( 1, "Cannot fetch" );
243 0 return;
244 }
245 5 ▶ $dbh->{mock_can_fetch}++ if $dbh->{mock_can_fetch} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $dbh->{"mock_can_fetch"} < 0 0 5 5
246  
247 # get the case conversion to use for hash key names (NAME/NAME_lc/NAME_uc)
248 5 ▶ my $hash_key_name = $sth->{Database}->FETCH('FetchHashKeyName') || 'NAME';
Condition50%1/2
$sth->{'Database'}->FETCH('FetchHashKeyName') || 'NAME'
l!l
50
MC/DC0%0/1
$sth->{'Database'}->FETCH('FetchHashKeyName') || 'NAME'
$sth->{'Database'}->FETCH('FetchHashKeyName')
Truth table50%1/2
A
A= $sth->{'Database'}->FETCH('FetchHashKeyName')
Aresult
11
00
249  
250 # get a hashref mapping field names to their corresponding indexes. indexes
251 # start at zero
252 5 my $names_hash = $sth->FETCH("${hash_key_name}_hash");
253  
254 # as of DBI v1.48, the $keyfield argument can be either an arrayref of field
255 # names/indexes or a single field name/index
256 5 ▶ my @key_fields = ref $keyfield ? @{$keyfield} : $keyfield;
Branch: 1 branch
BranchTrueFalseTotal
ref $keyfield ? : 3 2 5
257  
258 5 my $num_fields = $sth->FETCH('NUM_OF_FIELDS');
259  
260 # get the index(es) of the given key field(s). a key field can be specified
261 # as either the name of a field or an integer column number
262 5 my @key_indexes;
263 5 foreach my $field (@key_fields) {
264 6 ▶ if (defined $names_hash->{$field}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $names_hash->{$field}) { } 3 3 6
elsif (DBI::looks_like_number($field) and $field >= 1 and $field <= $num_fields) { } 3 0 3
265 3 push @key_indexes, $names_hash->{$field};
266 }
267 ▶ elsif (DBI::looks_like_number($field) && $field >= 1 && $field <= $num_fields) {
Condition33%2/6
DBI::looks_like_number($field) and $field >= 1 and $field <= $num_fields
!ll&&!rl&&r
003
DBI::looks_like_number($field) and $field >= 1
!ll&&!rl&&r
003
MC/DC0%0/3
DBI::looks_like_number($field) and $field >= 1 and $field <= $num_fields
DBI::looks_like_number($field) $field >= 1 $field <= $num_fields
Truth table25%1/4
A and B and C
A= DBI::looks_like_number($field)B= $field >= 1C= $field <= $num_fields
ABCresult
0XX0
10X0
1100
1111
268 # convert from column number to array index. column numbers start at
269 # one, while indexes start at zero
270 3 push @key_indexes, $field - 1;
271 }
272 else {
273 my $err = "Could not find key field '$field' (not one of " .
274 0 join(' ', keys %{$names_hash}) . ')';
275 0 $dbh->set_err( 1, $err );
276 0 return;
277 }
278 }
279  
280 5 my $tracker = $sth->FETCH('mock_my_history');
281 5 my $rethash = {};
282  
283 # now loop through all the records ...
284 5 ▶ while ( my $record = $tracker->next_record() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $record = $tracker->next_record) 10 5 15
285  
286 # populate the hash, adding a layer of nesting for each key field
287 # specified by the user
288 10 my $ref = $rethash;
289 10 foreach my $index (@key_indexes) {
290 12 my $value = $record->[$index];
291 12 ▶ $ref->{$value} = {} if ! defined $ref->{$value};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref->{$value} 12 0 12
292 12 $ref = $ref->{$value};
293 }
294  
295 # copy all of the returned data into the most-nested level of the hash
296 10 foreach my $field (keys %{$names_hash}) {
297 30 my $index = $names_hash->{$field};
298 30 $ref->{$field} = $record->[$index];
299 }
300 }
301  
302 5 return $rethash;
303 }
304  
305 6 ▶sub last_insert_id {
Subroutine last_insert_id: called CC=1 SCAR=0.0
Pod undocumented
306 6 my ( $sth, @params ) = @_;
307 6 return $sth->{Database}->last_insert_id( @params );
308 }
309  
310 38 ▶sub finish {
Subroutine finish: called CC=1 SCAR=0.0
Pod undocumented
311 38 my ($sth) = @_;
312 38 $sth->FETCH('mock_my_history')->is_finished('yes');
313 }
314  
315 43 ▶sub rows {
Subroutine rows: called CC=1 SCAR=0.0
Pod undocumented
316 43 my ($sth) = @_;
317 43 $sth->FETCH('mock_num_rows');
318 }
319  
320 131 ▶sub FETCH {
Subroutine FETCH: called CC=29 SCAR=35.0
321 131 my ( $sth, $attrib ) = @_;
322 131 $sth->trace_msg("Fetching ST attribute '$attrib'\n");
323 131 my $tracker = $sth->{mock_my_history};
324 131 $sth->trace_msg( "Retrieved tracker: " . ref($tracker) . "\n" );
325  
326 # NAME attributes
327 131 ▶ if ( $attrib eq 'NAME' ) {
Branch: 12 branches
BranchTrueFalseTotal
if ($attrib eq 'NAME') { } 12 119 131
elsif ($attrib eq 'NAME_lc') { } 2 117 119
elsif ($attrib eq 'NAME_uc') { } 1 116 117
elsif ($attrib eq 'NAME_hash') { } 6 110 116
elsif ($attrib eq 'NAME_hash_lc') { } 1 109 110
elsif ($attrib eq 'NAME_hash_uc') { } 1 108 109
elsif ($attrib eq 'NUM_OF_FIELDS') { } 2 106 108
elsif ($attrib eq 'NUM_OF_PARAMS') { } 1 105 106
elsif ($attrib eq 'TYPE') { } 0 105 105
elsif ($attrib eq 'Active') { } 5 100 105
elsif (exists $tracker->{'driver_attributes'}{$attrib}) { } 8 92 100
elsif (not $attrib =~ /^mock/) { } 4 88 92
328 12 return [ @{ $tracker->fields } ];
329 }
330 elsif ( $attrib eq 'NAME_lc' ) {
331 2 return [ map { lc($_) } @{ $tracker->fields } ];
332 }
333 elsif ( $attrib eq 'NAME_uc' ) {
334 1 return [ map { uc($_) } @{ $tracker->fields } ];
335 }
336  
337 # NAME_hash attributes
338 elsif ( $attrib eq 'NAME_hash' ) {
339 6 my $i = 0;
340 6 return { map { $_ => $i++ } @{ $tracker->fields } };
341 }
342 elsif ( $attrib eq 'NAME_hash_lc' ) {
343 1 my $i = 0;
344 1 return { map { lc($_) => $i++ } @{ $tracker->fields } };
345 }
346 elsif ( $attrib eq 'NAME_hash_uc' ) {
347 1 my $i = 0;
348 1 return { map { uc($_) => $i++ } @{ $tracker->fields } };
349 }
350  
351 # others
352 elsif ( $attrib eq 'NUM_OF_FIELDS' ) {
353 2 return $tracker->num_fields;
354 }
355 elsif ( $attrib eq 'NUM_OF_PARAMS' ) {
356 1 return $tracker->num_params;
357 }
358 elsif ( $attrib eq 'TYPE' ) {
359 0 my $num_fields = $tracker->num_fields;
360 0 return [ map { $DBI::SQL_VARCHAR } ( 0 .. $num_fields ) ];
361 }
362 elsif ( $attrib eq 'Active' ) {
363 5 return $tracker->is_active;
364 }
365 elsif ( exists $tracker->{driver_attributes}->{$attrib} ) {
366 8 return $tracker->{driver_attributes}->{$attrib};
367 }
368 elsif ( $attrib !~ /^mock/ ) {
369 4 ▶ if ( $sth->{Database}->{mock_attribute_aliases} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sth->{"Database"}{"mock_attribute_aliases"}) 0 4 4
370 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (exists do { $$sth{"Database"}{"mock_attribute_aliases"}{"st"} }->{$attrib}) 0 0 0
371 0 exists ${ $sth->{Database}->{mock_attribute_aliases}->{st} }
372 {$attrib} )
373 {
374 my $mock_attrib =
375 0 $sth->{Database}->{mock_attribute_aliases}->{st}->{$attrib};
376 0 ▶ if ( ref($mock_attrib) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $mock_attrib eq 'CODE') { } 0 0 0
377 0 return $mock_attrib->($sth);
378 }
379 else {
380 0 return $sth->FETCH($mock_attrib);
381 }
382 }
383 }
384 4 return $sth->SUPER::FETCH($attrib);
385 }
386  
387 # now do our stuff...
388  
389 88 ▶ if ( $attrib eq 'mock_my_history' ) {
Branch: 12 branches
BranchTrueFalseTotal
if ($attrib eq 'mock_my_history') { } 0 88 88
elsif ($attrib eq 'mock_execution_history') { } 1 87 88
elsif ($attrib eq 'mock_statement') { } 2 85 87
elsif ($attrib eq 'mock_params') { } 5 80 85
elsif ($attrib eq 'mock_param_attrs') { } 3 77 80
elsif ($attrib eq 'mock_records') { } 1 76 77
elsif ($attrib eq 'mock_num_records' or $attrib eq 'mock_num_rows') { } 48 28 76
elsif ($attrib eq 'mock_current_record_num') { } 11 17 28
elsif ($attrib eq 'mock_fields') { } 1 16 17
elsif ($attrib eq 'mock_is_executed') { } 4 12 16
elsif ($attrib eq 'mock_is_finished') { } 5 7 12
elsif ($attrib eq 'mock_is_depleted') { } 7 0 7
390 0 return $tracker;
391 }
392 elsif ( $attrib eq 'mock_execution_history' ) {
393 1 return $tracker->execution_history();
394 }
395 elsif ( $attrib eq 'mock_statement' ) {
396 2 return $tracker->statement;
397 }
398 elsif ( $attrib eq 'mock_params' ) {
399 5 return $tracker->bound_params;
400 }
401 elsif ( $attrib eq 'mock_param_attrs' ) {
402 3 return $tracker->bound_param_attrs;
403 }
404 elsif ( $attrib eq 'mock_records' ) {
405 1 return $tracker->return_data;
406 }
407 ▶ elsif ( $attrib eq 'mock_num_records' || $attrib eq 'mock_num_rows' ) {
Condition100%3/3
$attrib eq "mock_num_records" or $attrib eq "mock_num_rows"
l!l&&r!l&&!r
34528
MC/DC100%2/2
$attrib eq "mock_num_records" or $attrib eq "mock_num_rows"
$attrib eq "mock_num_records" $attrib eq "mock_num_rows"
Truth table100%3/3
A or B
A= $attrib eq "mock_num_records"B= $attrib eq "mock_num_rows"
ABresult
1X1
011
000
408 48 return $tracker->num_rows;
409 }
410 elsif ( $attrib eq 'mock_current_record_num' ) {
411 11 return $tracker->current_record_num;
412 }
413 elsif ( $attrib eq 'mock_fields' ) {
414 1 return $tracker->fields;
415 }
416 elsif ( $attrib eq 'mock_is_executed' ) {
417 4 return $tracker->is_executed;
418 }
419 elsif ( $attrib eq 'mock_is_finished' ) {
420 5 return $tracker->is_finished;
421 }
422 elsif ( $attrib eq 'mock_is_depleted' ) {
423 7 return $tracker->is_depleted;
424 }
425 else {
426 0 die "I don't know how to retrieve statement attribute '$attrib'\n";
427 }
428 }
429  
430 751 ▶sub STORE {
Subroutine STORE: called CC=4 SCAR=13.9
431 751 my ( $sth, $attrib, $value ) = @_;
432 751 $sth->trace_msg("Storing ST attribute '$attrib'\n");
433 751 ▶ if ( $attrib =~ /^mock/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($attrib =~ /^mock/) { } 153 598 751
elsif ($attrib =~ /^NAME/) { } 229 369 598
434 153 return $sth->{$attrib} = $value;
435 }
436 elsif ( $attrib =~ /^NAME/ ) {
437  
438 # no-op...
439 229 return;
440 }
441 else {
442 369 ▶ $value ||= 0;
Condition100%2/2
$value ||= 0
l!l
217152
MC/DC100%1/1
$value ||= 0
$value
Truth table100%2/2
A
A= $value
Aresult
11
00
443 369 return $sth->SUPER::STORE( $attrib, $value );
444 }
445 }
446  
447 153 ▶sub DESTROY { undef }
Subroutine DESTROY: called CC=1 SCAR=0.0
448  
449 41 1;
« Mock/db.pm ↑ Summary Mock/Session.pm »